parent
12635e603f
commit
872d55cb4c
@ -35,7 +35,7 @@ use std::sync::Arc;
|
|||||||
use bitcoin::consensus::encode::serialize;
|
use bitcoin::consensus::encode::serialize;
|
||||||
use bitcoin::util::bip32::ChildNumber;
|
use bitcoin::util::bip32::ChildNumber;
|
||||||
use bitcoin::util::psbt::PartiallySignedTransaction as PSBT;
|
use bitcoin::util::psbt::PartiallySignedTransaction as PSBT;
|
||||||
use bitcoin::{Address, Network, OutPoint, Script, SigHashType, Transaction, TxOut, Txid};
|
use bitcoin::{Address, Network, OutPoint, Script, Transaction, TxOut, Txid};
|
||||||
|
|
||||||
use miniscript::psbt::PsbtInputSatisfier;
|
use miniscript::psbt::PsbtInputSatisfier;
|
||||||
|
|
||||||
@ -1025,8 +1025,11 @@ where
|
|||||||
None => continue,
|
None => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add sighash, default is obviously "ALL"
|
// Only set it if the builder has a custom one, otherwise leave blank which defaults to
|
||||||
psbt_input.sighash_type = builder.sighash.or(Some(SigHashType::All));
|
// SIGHASH_ALL
|
||||||
|
if let Some(sighash_type) = builder.sighash {
|
||||||
|
psbt_input.sighash_type = Some(sighash_type);
|
||||||
|
}
|
||||||
|
|
||||||
// Try to find the prev_script in our db to figure out if this is internal or external,
|
// Try to find the prev_script in our db to figure out if this is internal or external,
|
||||||
// and the derivation index
|
// and the derivation index
|
||||||
@ -1742,7 +1745,7 @@ mod test {
|
|||||||
)]))
|
)]))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(psbt.inputs[0].sighash_type, Some(bitcoin::SigHashType::All));
|
assert_eq!(psbt.inputs[0].sighash_type, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -136,8 +136,6 @@ pub enum SignerError {
|
|||||||
InvalidKey,
|
InvalidKey,
|
||||||
/// The user canceled the operation
|
/// The user canceled the operation
|
||||||
UserCanceled,
|
UserCanceled,
|
||||||
/// The sighash is missing in the PSBT input
|
|
||||||
MissingSighash,
|
|
||||||
/// Input index is out of range
|
/// Input index is out of range
|
||||||
InputIndexOutOfRange,
|
InputIndexOutOfRange,
|
||||||
/// The `non_witness_utxo` field of the transaction is required to sign this input
|
/// The `non_witness_utxo` field of the transaction is required to sign this input
|
||||||
@ -432,7 +430,7 @@ impl ComputeSighash for Legacy {
|
|||||||
let psbt_input = &psbt.inputs[input_index];
|
let psbt_input = &psbt.inputs[input_index];
|
||||||
let tx_input = &psbt.global.unsigned_tx.input[input_index];
|
let tx_input = &psbt.global.unsigned_tx.input[input_index];
|
||||||
|
|
||||||
let sighash = psbt_input.sighash_type.ok_or(SignerError::MissingSighash)?;
|
let sighash = psbt_input.sighash_type.unwrap_or(SigHashType::All);
|
||||||
let script = match psbt_input.redeem_script {
|
let script = match psbt_input.redeem_script {
|
||||||
Some(ref redeem_script) => redeem_script.clone(),
|
Some(ref redeem_script) => redeem_script.clone(),
|
||||||
None => {
|
None => {
|
||||||
@ -479,7 +477,7 @@ impl ComputeSighash for Segwitv0 {
|
|||||||
|
|
||||||
let psbt_input = &psbt.inputs[input_index];
|
let psbt_input = &psbt.inputs[input_index];
|
||||||
|
|
||||||
let sighash = psbt_input.sighash_type.ok_or(SignerError::MissingSighash)?;
|
let sighash = psbt_input.sighash_type.unwrap_or(SigHashType::All);
|
||||||
|
|
||||||
let witness_utxo = psbt_input
|
let witness_utxo = psbt_input
|
||||||
.witness_utxo
|
.witness_utxo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user