Browse Source

refactor utxo selector creation

bwt
Craig Raw 5 years ago
parent
commit
4d51bb40c2
  1. 2
      drongo
  2. 28
      src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java

2
drongo

@ -1 +1 @@
Subproject commit 9d272c0eb2785f0d4f745f7d1ede115e91ab4e28
Subproject commit 832ca8f257559864823c83d8d29dc2276f44fa51

28
src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java

@ -315,34 +315,16 @@ public class SendController extends WalletFormController implements Initializabl
walletTransactionProperty.setValue(null);
}
private List<UtxoSelector> getUtxoSelectors() {
private List<UtxoSelector> getUtxoSelectors() throws InvalidAddressException {
if(utxoSelectorProperty.get() != null) {
return List.of(utxoSelectorProperty.get());
}
return List.of(getBnBSelector(), getKnapsackSelector());
}
private UtxoSelector getBnBSelector() {
try {
int noInputsWeightUnits = getWalletForm().getWallet().getNoInputsWeightUnits(getRecipientAddress());
return new BnBUtxoSelector(getWalletForm().getWallet(), noInputsWeightUnits, getFeeRate(), getMinimumFeeRate());
} catch(InvalidAddressException e) {
throw new RuntimeException(e);
}
}
private UtxoSelector getKnapsackSelector() {
return new KnapsackUtxoSelector();
}
private UtxoSelector getPrioritySelector() {
Integer blockHeight = AppController.getCurrentBlockHeight();
if(blockHeight == null) {
blockHeight = getWalletForm().getWallet().getStoredBlockHeight();
}
Wallet wallet = getWalletForm().getWallet();
long noInputsFee = wallet.getNoInputsFee(getRecipientAddress(), getFeeRate());
long costOfChange = wallet.getCostOfChange(getFeeRate(), getMinimumFeeRate());
return new PriorityUtxoSelector(blockHeight);
return List.of(new BnBUtxoSelector(noInputsFee, costOfChange), new KnapsackUtxoSelector(noInputsFee));
}
private boolean isValidRecipientAddress() {

Loading…
Cancel
Save