diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2023-10-17 22:19:05 +0100 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2023-10-17 22:26:25 +0100 |
commit | 9c30f5ef9d6712539cb8dc0f52b3a2206a25e074 (patch) | |
tree | 0095f9406cfcf58a28ff530a2a6c46406f9f8efc /src | |
parent | fbcf1029a7ba47d07a4566cf1f9d2e7b4870304a (diff) | |
parent | 00a52e63946d5a90cdfb68204373d9c23d885161 (diff) |
Merge bitcoin-core/gui#766: Fix coin control input size accounting for taproot spends
00a52e63946d5a90cdfb68204373d9c23d885161 gui: fix coin control input size accounting for taproot spends (Sebastian Falbesoner)
Pull request description:
If manual coin control is used in the GUI, the input size accounting for P2TR is currently overshooting, as it still assumes P2WPKH (segwitv0) spends which have a larger witness, as ECDSA signatures are longer and the pubkey also has to be provided. Fix that by adding sizes depending on the witness version. Note that the total accounting including outputs is still off and there is some weird logic involved depending on whether SFFO is used, but it's (hopefully) a first step into the right direction.
ACKs for top commit:
maflcko:
lgtm ACK 00a52e63946d5a90cdfb68204373d9c23d885161
furszy:
utACK 00a52e6394
Tree-SHA512: 9633642f8473247cc3d8e6e0ef502fd515e1dde0e2939d28d6754d0cececedd6a328df22a3d4c85eb2846fd0417cf224b92594613f6e84ada82d2d7d84fc455f
Diffstat (limited to 'src')
-rw-r--r-- | src/qt/coincontroldialog.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 38c7656e00..70aa9bc8da 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -421,7 +421,19 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel * std::vector<unsigned char> witnessprogram; if (out.txout.scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) { - nBytesInputs += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4); + // add input skeleton bytes (outpoint, scriptSig size, nSequence) + nBytesInputs += (32 + 4 + 1 + 4); + + if (witnessversion == 0) { // P2WPKH + // 1 WU (witness item count) + 72 WU (ECDSA signature with len byte) + 34 WU (pubkey with len byte) + nBytesInputs += 107 / WITNESS_SCALE_FACTOR; + } else if (witnessversion == 1) { // P2TR key-path spend + // 1 WU (witness item count) + 65 WU (Schnorr signature with len byte) + nBytesInputs += 66 / WITNESS_SCALE_FACTOR; + } else { + // not supported, should be unreachable + throw std::runtime_error("Trying to spend future segwit version script"); + } fWitness = true; } else if(ExtractDestination(out.txout.scriptPubKey, address)) |