refactor utxo selector creation

This commit is contained in:
Craig Raw 2020-07-14 13:36:43 +02:00
parent e7b511fc74
commit 4d51bb40c2
2 changed files with 6 additions and 24 deletions

2
drongo

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

View file

@ -315,34 +315,16 @@ public class SendController extends WalletFormController implements Initializabl
walletTransactionProperty.setValue(null); walletTransactionProperty.setValue(null);
} }
private List<UtxoSelector> getUtxoSelectors() { private List<UtxoSelector> getUtxoSelectors() throws InvalidAddressException {
if(utxoSelectorProperty.get() != null) { if(utxoSelectorProperty.get() != null) {
return List.of(utxoSelectorProperty.get()); return List.of(utxoSelectorProperty.get());
} }
return List.of(getBnBSelector(), getKnapsackSelector()); Wallet wallet = getWalletForm().getWallet();
} long noInputsFee = wallet.getNoInputsFee(getRecipientAddress(), getFeeRate());
long costOfChange = wallet.getCostOfChange(getFeeRate(), getMinimumFeeRate());
private UtxoSelector getBnBSelector() { return List.of(new BnBUtxoSelector(noInputsFee, costOfChange), new KnapsackUtxoSelector(noInputsFee));
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();
}
return new PriorityUtxoSelector(blockHeight);
} }
private boolean isValidRecipientAddress() { private boolean isValidRecipientAddress() {