mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-11-05 11:56:37 +00:00
- Added code findings for WalletTransaction creation
This commit is contained in:
parent
b1a3dc6411
commit
055bc65bff
1 changed files with 47 additions and 7 deletions
|
|
@ -2,23 +2,33 @@ package com.sparrowwallet.sparrow.joinstr;
|
|||
|
||||
import com.sparrowwallet.drongo.KeyPurpose;
|
||||
import com.sparrowwallet.drongo.address.Address;
|
||||
import com.sparrowwallet.drongo.protocol.Transaction;
|
||||
import com.sparrowwallet.drongo.psbt.PSBT;
|
||||
import com.sparrowwallet.drongo.wallet.CoinbaseTxoFilter;
|
||||
import com.sparrowwallet.drongo.wallet.FrozenTxoFilter;
|
||||
import com.sparrowwallet.drongo.wallet.Payment;
|
||||
import com.sparrowwallet.drongo.wallet.SpentTxoFilter;
|
||||
import com.sparrowwallet.drongo.wallet.TxoFilter;
|
||||
import com.sparrowwallet.drongo.wallet.UtxoSelector;
|
||||
import com.sparrowwallet.drongo.wallet.WalletNode;
|
||||
import com.sparrowwallet.drongo.wallet.WalletTransaction;
|
||||
import com.sparrowwallet.sparrow.AppServices;
|
||||
import com.sparrowwallet.sparrow.control.QRScanDialog;
|
||||
import com.sparrowwallet.sparrow.net.Tor;
|
||||
import com.sparrowwallet.sparrow.wallet.NodeEntry;
|
||||
import com.sparrowwallet.sparrow.wallet.WalletForm;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
public class JoinstrPool {
|
||||
|
||||
private final String relay;
|
||||
private final Integer port;
|
||||
private final String pubkey;
|
||||
private final Double denomination;
|
||||
private final long denomination; // Should be in sats, like transaction amounts
|
||||
private final WalletForm walletForm; // [FormController].getWalletForm()
|
||||
|
||||
public JoinstrPool(WalletForm walletForm,String relay, Integer port, String pubkey, Double denomination) {
|
||||
public JoinstrPool(WalletForm walletForm,String relay, Integer port, String pubkey, long denomination) {
|
||||
|
||||
this.walletForm = walletForm;
|
||||
this.relay = relay;
|
||||
|
|
@ -40,7 +50,7 @@ public class JoinstrPool {
|
|||
return pubkey;
|
||||
}
|
||||
|
||||
public Double getDenomination() {
|
||||
public long getDenomination() {
|
||||
return denomination;
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +69,6 @@ public class JoinstrPool {
|
|||
public void createPSBT() {
|
||||
|
||||
Address sendAddress = getNewSendAddress();
|
||||
PSBT psbt;
|
||||
|
||||
/* String to byte[]
|
||||
|
||||
|
|
@ -99,10 +108,41 @@ public class JoinstrPool {
|
|||
psbt = txdata.getPsbt();
|
||||
*/
|
||||
|
||||
// PSBT from WalletTransaction
|
||||
|
||||
List<UtxoSelector> utxoSelectors;
|
||||
/// TODO select UTXO for transaction
|
||||
|
||||
SpentTxoFilter spentTxoFilter = new SpentTxoFilter(null);
|
||||
List<TxoFilter> txoFilters = List.of(spentTxoFilter, new FrozenTxoFilter(), new CoinbaseTxoFilter(walletForm.getWallet()));
|
||||
|
||||
long satsLeft = 0L;
|
||||
Payment coinjoinPayment = new Payment(sendAddress, "coinjoin", denomination, false);
|
||||
/// TODO create multiple coinjoin payments for selected UTXO
|
||||
Payment changePayment = new Payment(sendAddress, "change", satsLeft, false);
|
||||
List<Payment> payments = List.of(coinjoinPayment, changePayment);
|
||||
|
||||
List<byte[]> opReturns = null;
|
||||
|
||||
Set<WalletNode> excludedChangeNodes;
|
||||
/// TODO fill excludedChangeNodes
|
||||
|
||||
double feeRate = 10.0;
|
||||
double longTermFeeRate = 10.0;
|
||||
Long fee = 10L;
|
||||
Integer currentBlockHeight = AppServices.getCurrentBlockHeight();
|
||||
boolean groupByAddress = false;
|
||||
boolean includeMempoolOutputs = false;
|
||||
|
||||
WalletTransaction toSign = walletForm.getWallet().createWalletTransaction(utxoSelectors, txoFilters, payments, opReturns, excludedChangeNodes, feeRate, longTermFeeRate, fee, currentBlockHeight, groupByAddress, includeMempoolOutputs);
|
||||
PSBT psbt = toSign.createPSBT();
|
||||
|
||||
// decryptedWallet.sign(psbt);
|
||||
// decryptedWallet.finalise(psbt);
|
||||
// Transaction transaction = psbt.extractTransaction();
|
||||
|
||||
/* PSBT from Transaction
|
||||
|
||||
Transaction toSign;
|
||||
/// TODO fill toSign
|
||||
|
||||
PSBT psbt = new PSBT(toSign);
|
||||
PSBTInput psbtInput = psbt.getPsbtInputs().get(0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue