From d154fe73d7e8116794d8a84d37fa1a3fefb4cafd Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Wed, 16 Oct 2024 18:35:16 +0200 Subject: [PATCH] use p2pkh vout instead of p2pk for change when -pubkey specified this will help Iguana identify the change UTXOs and use them for splitting. --- src/wallet/wallet.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 05fe037808..a248aa0d05 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3843,6 +3843,13 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt else { //fprintf(stderr,"use notary pubkey\n"); + + // If a valid notary pubkey is passed, the change will be sent to the corresponding address + // as a standard P2PKH vout, not P2PK, so Iguana can easily split it, etc. + vchPubKey = CPubKey(ParseHex(NOTARY_PUBKEY)); + if (vchPubKey.IsValid()) { + scriptChange = GetScriptForDestination(vchPubKey.GetID()); + } else scriptChange = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } }