diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-10-07 01:01:57 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-10-07 01:07:21 +0200 |
commit | 00a52e63946d5a90cdfb68204373d9c23d885161 (patch) | |
tree | bdd9b8134eda2436a70b73e81f3582c1a9f36691 | |
parent | 54bdb6e0745934ad9ae6c77628f2382a83b9a1f0 (diff) |
gui: fix coin control input size accounting for taproot spends
-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)) |