mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-26 18:16:45 +00:00
dont add non-witness utxo when keystores are exclusively coldcard or cobovault
This commit is contained in:
parent
93d494fcde
commit
4b682fb3e7
3 changed files with 18 additions and 4 deletions
|
@ -87,6 +87,8 @@ public class PSBT {
|
|||
this.version = version;
|
||||
}
|
||||
|
||||
boolean alwaysIncludeWitnessUtxo = wallet.getKeystores().stream().anyMatch(keystore -> keystore.getWalletModel().alwaysIncludeNonWitnessUtxo());
|
||||
|
||||
int inputIndex = 0;
|
||||
for(Iterator<Map.Entry<BlockTransactionHashIndex, WalletNode>> iter = walletTransaction.getSelectedUtxos().entrySet().iterator(); iter.hasNext(); inputIndex++) {
|
||||
Map.Entry<BlockTransactionHashIndex, WalletNode> utxoEntry = iter.next();
|
||||
|
@ -112,7 +114,7 @@ public class PSBT {
|
|||
derivedPublicKeys.put(keystore.getPubKey(walletNode), keystore.getKeyDerivation().extend(walletNode.getDerivation()));
|
||||
}
|
||||
|
||||
PSBTInput psbtInput = new PSBTInput(wallet.getScriptType(), transaction, inputIndex, utxo, utxoIndex, redeemScript, witnessScript, derivedPublicKeys, Collections.emptyMap());
|
||||
PSBTInput psbtInput = new PSBTInput(wallet.getScriptType(), transaction, inputIndex, utxo, utxoIndex, redeemScript, witnessScript, derivedPublicKeys, Collections.emptyMap(), alwaysIncludeWitnessUtxo);
|
||||
psbtInputs.add(psbtInput);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,16 +48,20 @@ public class PSBTInput {
|
|||
this.index = index;
|
||||
}
|
||||
|
||||
PSBTInput(ScriptType scriptType, Transaction transaction, int index, Transaction utxo, int utxoIndex, Script redeemScript, Script witnessScript, Map<ECKey, KeyDerivation> derivedPublicKeys, Map<String, String> proprietary) {
|
||||
PSBTInput(ScriptType scriptType, Transaction transaction, int index, Transaction utxo, int utxoIndex, Script redeemScript, Script witnessScript, Map<ECKey, KeyDerivation> derivedPublicKeys, Map<String, String> proprietary, boolean alwaysAddNonWitnessTx) {
|
||||
this(transaction, index);
|
||||
sigHash = SigHash.ALL;
|
||||
|
||||
if(Arrays.asList(ScriptType.WITNESS_TYPES).contains(scriptType)) {
|
||||
this.witnessUtxo = utxo.getOutputs().get(utxoIndex);
|
||||
} else {
|
||||
this.nonWitnessUtxo = utxo;
|
||||
}
|
||||
|
||||
//Add non-witness UTXO to segwit types to handle Trezor and Ledger requirements
|
||||
this.nonWitnessUtxo = utxo;
|
||||
if(alwaysAddNonWitnessTx) {
|
||||
//Add non-witness UTXO to segwit types to handle Trezor, Bitbox and Ledger requirements
|
||||
this.nonWitnessUtxo = utxo;
|
||||
}
|
||||
|
||||
this.redeemScript = redeemScript;
|
||||
this.witnessScript = witnessScript;
|
||||
|
|
|
@ -35,6 +35,14 @@ public enum WalletModel {
|
|||
return this.toString().toLowerCase();
|
||||
}
|
||||
|
||||
public boolean alwaysIncludeNonWitnessUtxo() {
|
||||
if(this == COLDCARD || this == COBO_VAULT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean requiresPinPrompt() {
|
||||
return (this == TREZOR_1 || this == KEEPKEY);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue