Skip to content

Commit f37c822

Browse files
committed
Set the txversion to 1 when creating a raw transaction through rpc. Handle the "key" marking parameter properly and show the generate privkey only if no key parameter has been passed
1 parent 7029bcd commit f37c822

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/rpc/rawtransaction_util.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in)
146146
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf)
147147
{
148148
CMutableTransaction rawTx;
149+
rawTx.nVersion = 1; // todo make this more general for the future where tx version may be larger
149150

150151
if (!locktime.isNull()) {
151152
int64_t nLockTime = locktime.getInt<int64_t>();

src/wallet/rpc/spend.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ void MarkPubKeysHLDK(std::vector<uchar>& pubkeyH, std::vector<uchar>& pubkeyL, s
474474
}
475475

476476
unsigned int lenKeyHex = mark.keyHex.size();
477-
if (lenKeyHex==32) {
477+
if (lenKeyHex==32) { // nostr public key
478478
pubkeyK.push_back(2); // (I think) prefix 02 is assumed for nostr
479479
for (int i=0; i<lenKeyHex; i++) {
480480
pubkeyK.push_back(mark.keyHex[i]);
@@ -483,6 +483,10 @@ void MarkPubKeysHLDK(std::vector<uchar>& pubkeyH, std::vector<uchar>& pubkeyL, s
483483
pubkeyH.push_back(0);
484484
}
485485
}
486+
else if (lenKeyHex==33) { // compressed public key
487+
for (int i=0; i<lenKeyHex; i++)
488+
pubkeyK.push_back(mark.keyHex[i]);
489+
}
486490
}
487491

488492
RPCHelpMan mark()
@@ -678,9 +682,10 @@ RPCHelpMan mark()
678682
CKey key;
679683
key.MakeNewKey(false);
680684
CPubKey spendKey = key.GetPubKey();
681-
pwallet->WalletLogPrintf("private key for %s = %s\n",spendKey.GetHash().GetHex(),EncodeSecret(key));
682685
std::vector<uchar> pubkeyH, pubkeyL, pubkeyD, pubkeyK;
683686
MarkPubKeysHLDK(pubkeyH,pubkeyL,pubkeyD,pubkeyK,mark);
687+
if (!pubkeyK.size())
688+
pwallet->WalletLogPrintf("private key for %s = %s\n",spendKey.GetHash().GetHex(),EncodeSecret(key));
684689
CPubKey hashKey;
685690
CPubKey linkKey;
686691
CPubKey descKey;

0 commit comments

Comments
 (0)