mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-05 03: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,8 +307,12 @@ public class Transaction extends ChildMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script) {
|
public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script) {
|
||||||
|
if(isSegwit()) {
|
||||||
|
return addInput(spendTxHash, outputIndex, script, new TransactionWitness(this));
|
||||||
|
} else {
|
||||||
return addInput(new TransactionInput(this, new TransactionOutPoint(spendTxHash, outputIndex), script.getProgram()));
|
return addInput(new TransactionInput(this, new TransactionOutPoint(spendTxHash, outputIndex), script.getProgram()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script, TransactionWitness witness) {
|
public TransactionInput addInput(Sha256Hash spendTxHash, long outputIndex, Script script, TransactionWitness witness) {
|
||||||
if(!isSegwit()) {
|
if(!isSegwit()) {
|
||||||
|
|
|
@ -33,6 +33,10 @@ public class TransactionWitness extends ChildMessage {
|
||||||
pushes.add(witnessScript.getProgram());
|
pushes.add(witnessScript.getProgram());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TransactionWitness(Transaction transaction) {
|
||||||
|
this(transaction, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
public TransactionWitness(Transaction transaction, List<byte[]> witnesses) {
|
public TransactionWitness(Transaction transaction, List<byte[]> witnesses) {
|
||||||
setParent(transaction);
|
setParent(transaction);
|
||||||
this.pushes = witnesses;
|
this.pushes = witnesses;
|
||||||
|
|
|
@ -484,7 +484,7 @@ public class PSBT {
|
||||||
if(psbtInput.getFinalScriptWitness() != null) {
|
if(psbtInput.getFinalScriptWitness() != null) {
|
||||||
txInput.setWitness(psbtInput.getFinalScriptWitness());
|
txInput.setWitness(psbtInput.getFinalScriptWitness());
|
||||||
} else {
|
} else {
|
||||||
txInput.setWitness(new TransactionWitness(transaction, Collections.emptyList()));
|
txInput.setWitness(new TransactionWitness(transaction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue