mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-02 18:26:43 +00:00
handle adding non witness inputs to segwit transactions
This commit is contained in:
parent
70d0b7afcd
commit
0466755883
3 changed files with 10 additions and 2 deletions
|
@ -307,7 +307,11 @@ public class Transaction extends ChildMessage {
|
|||
}
|
||||
|
||||
public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script) {
|
||||
return addInput(new TransactionInput(this, new TransactionOutPoint(spendTxHash, outputIndex), script.getProgram()));
|
||||
if(isSegwit()) {
|
||||
return addInput(spendTxHash, outputIndex, script, new TransactionWitness(this));
|
||||
} else {
|
||||
return addInput(new TransactionInput(this, new TransactionOutPoint(spendTxHash, outputIndex), script.getProgram()));
|
||||
}
|
||||
}
|
||||
|
||||
public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script, TransactionWitness witness) {
|
||||
|
|
|
@ -33,6 +33,10 @@ public class TransactionWitness extends ChildMessage {
|
|||
pushes.add(witnessScript.getProgram());
|
||||
}
|
||||
|
||||
public TransactionWitness(Transaction transaction) {
|
||||
this(transaction, new ArrayList<>());
|
||||
}
|
||||
|
||||
public TransactionWitness(Transaction transaction, List<byte[]> witnesses) {
|
||||
setParent(transaction);
|
||||
this.pushes = witnesses;
|
||||
|
|
|
@ -484,7 +484,7 @@ public class PSBT {
|
|||
if(psbtInput.getFinalScriptWitness() != null) {
|
||||
txInput.setWitness(psbtInput.getFinalScriptWitness());
|
||||
} else {
|
||||
txInput.setWitness(new TransactionWitness(transaction, Collections.emptyList()));
|
||||
txInput.setWitness(new TransactionWitness(transaction));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue