mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
refactor utxo selector creation
This commit is contained in:
parent
e7b511fc74
commit
4d51bb40c2
2 changed files with 6 additions and 24 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
|||
Subproject commit 9d272c0eb2785f0d4f745f7d1ede115e91ab4e28
|
||||
Subproject commit 832ca8f257559864823c83d8d29dc2276f44fa51
|
|
@ -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());
|
||||
}
|
||||
Wallet wallet = getWalletForm().getWallet();
|
||||
long noInputsFee = wallet.getNoInputsFee(getRecipientAddress(), getFeeRate());
|
||||
long costOfChange = wallet.getCostOfChange(getFeeRate(), getMinimumFeeRate());
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
return new PriorityUtxoSelector(blockHeight);
|
||||
return List.of(new BnBUtxoSelector(noInputsFee, costOfChange), new KnapsackUtxoSelector(noInputsFee));
|
||||
}
|
||||
|
||||
private boolean isValidRecipientAddress() {
|
||||
|
|
Loading…
Reference in a new issue