use crate::signer::{SignOptions, SignerError};
use crate::wallet::AddressIndex::{LastUnused, New, Peek, Reset};
+ // The satisfaction size of a P2WPKH is 112 WU =
+ // 1 (elements in witness) + 1 (OP_PUSH) + 33 (pk) + 1 (OP_PUSH) + 72 (signature + sighash) + 1*4 (script len)
+ // On the witness itself, we have to push once for the pk (33WU) and once for signature + sighash (72WU), for
+ // a total of 105 WU.
+ // Here, we push just once for simplicity, so we have to add an extra byte for the missing
+ // OP_PUSH.
+ const P2WPKH_FAKE_WITNESS_SIZE: usize = 106;
+
#[test]
fn test_cache_addresses_fixed() {
let db = MemoryDatabase::new();
$(
$( $add_signature )*
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
}
)*
let txid = tx.txid();
// skip saving the new utxos, we know they can't be used anyways
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let txid = tx.txid();
// skip saving the new utxos, we know they can't be used anyways
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let mut tx = psbt.extract_tx();
let txid = tx.txid();
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let mut tx = psbt.extract_tx();
let txid = tx.txid();
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let mut tx = psbt.extract_tx();
let txid = tx.txid();
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let mut tx = psbt.extract_tx();
let txid = tx.txid();
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let txid = tx.txid();
// skip saving the new utxos, we know they can't be used anyways
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let txid = tx.txid();
// skip saving the new utxos, we know they can't be used anyways
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let txid = tx.txid();
// skip saving the new utxos, we know they can't be used anyways
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let txid = tx.txid();
// skip saving the new utxos, we know they can't be used anyways
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let txid = tx.txid();
// skip saving the new utxos, we know they can't be used anyways
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let txid = tx.txid();
// skip saving the new utxos, we know they can't be used anyways
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let mut tx = psbt.extract_tx();
let txid = tx.txid();
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()
let mut tx = psbt.extract_tx();
let txid = tx.txid();
for txin in &mut tx.input {
- txin.witness.push([0x00; 108]); // fake signature
+ txin.witness.push([0x00; P2WPKH_FAKE_WITNESS_SIZE]); // fake signature
wallet
.database
.borrow_mut()