mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
set all witness utxos on psbt inputs before attempting to sign sweep tx
This commit is contained in:
parent
0745d21761
commit
7f2c07c918
1 changed files with 7 additions and 1 deletions
|
@ -378,11 +378,17 @@ public class PrivateKeySweepDialog extends Dialog<Transaction> {
|
||||||
transaction.addOutput(new TransactionOutput(transaction, total - fee, destAddress.getOutputScript()));
|
transaction.addOutput(new TransactionOutput(transaction, total - fee, destAddress.getOutputScript()));
|
||||||
|
|
||||||
PSBT psbt = new PSBT(transaction);
|
PSBT psbt = new PSBT(transaction);
|
||||||
|
//Set witness UTXOs on PSBT inputs first - they are all required when hashing for a Taproot signature
|
||||||
|
for(int i = 0; i < txOutputs.size(); i++) {
|
||||||
|
TransactionOutput utxoOutput = txOutputs.get(i);
|
||||||
|
PSBTInput psbtInput = psbt.getPsbtInputs().get(i);
|
||||||
|
psbtInput.setWitnessUtxo(utxoOutput);
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < txOutputs.size(); i++) {
|
for(int i = 0; i < txOutputs.size(); i++) {
|
||||||
TransactionOutput utxoOutput = txOutputs.get(i);
|
TransactionOutput utxoOutput = txOutputs.get(i);
|
||||||
TransactionInput txInput = transaction.getInputs().get(i);
|
TransactionInput txInput = transaction.getInputs().get(i);
|
||||||
PSBTInput psbtInput = psbt.getPsbtInputs().get(i);
|
PSBTInput psbtInput = psbt.getPsbtInputs().get(i);
|
||||||
psbtInput.setWitnessUtxo(utxoOutput);
|
|
||||||
|
|
||||||
if(ScriptType.P2SH.isScriptType(utxoOutput.getScript())) {
|
if(ScriptType.P2SH.isScriptType(utxoOutput.getScript())) {
|
||||||
psbtInput.setRedeemScript(txInput.getScriptSig().getFirstNestedScript());
|
psbtInput.setRedeemScript(txInput.getScriptSig().getFirstNestedScript());
|
||||||
|
|
Loading…
Reference in a new issue