mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-25 17:46:44 +00:00
support adding op return data when creating wallet transactions
This commit is contained in:
parent
57290a20a1
commit
eb49c97133
1 changed files with 6 additions and 1 deletions
|
@ -665,7 +665,7 @@ public class Wallet extends Persistable implements Comparable<Wallet> {
|
|||
return getFee(changeOutput, feeRate, longTermFeeRate);
|
||||
}
|
||||
|
||||
public WalletTransaction createWalletTransaction(List<UtxoSelector> utxoSelectors, List<UtxoFilter> utxoFilters, List<Payment> payments, Set<WalletNode> excludedChangeNodes, double feeRate, double longTermFeeRate, Long fee, Integer currentBlockHeight, boolean groupByAddress, boolean includeMempoolOutputs, boolean includeSpentMempoolOutputs) throws InsufficientFundsException {
|
||||
public WalletTransaction createWalletTransaction(List<UtxoSelector> utxoSelectors, List<UtxoFilter> utxoFilters, List<Payment> payments, List<byte[]> opReturns, Set<WalletNode> excludedChangeNodes, double feeRate, double longTermFeeRate, Long fee, Integer currentBlockHeight, boolean groupByAddress, boolean includeMempoolOutputs, boolean includeSpentMempoolOutputs) throws InsufficientFundsException {
|
||||
boolean sendMax = payments.stream().anyMatch(Payment::isSendMax);
|
||||
long totalPaymentAmount = payments.stream().map(Payment::getAmount).mapToLong(v -> v).sum();
|
||||
long totalUtxoValue = getWalletUtxos().keySet().stream().mapToLong(BlockTransactionHashIndex::getValue).sum();
|
||||
|
@ -728,6 +728,11 @@ public class Wallet extends Persistable implements Comparable<Wallet> {
|
|||
transaction.addOutput(payment.getAmount(), payment.getAddress());
|
||||
}
|
||||
|
||||
//Add OP_RETURNs
|
||||
for(byte[] opReturn : opReturns) {
|
||||
transaction.addOutput(0L, new Script(List.of(ScriptChunk.fromOpcode(ScriptOpCodes.OP_RETURN), ScriptChunk.fromData(opReturn))));
|
||||
}
|
||||
|
||||
double noChangeVSize = transaction.getVirtualSize();
|
||||
long noChangeFeeRequiredAmt = (fee == null ? (long)Math.floor(feeRate * noChangeVSize) : fee);
|
||||
|
||||
|
|
Loading…
Reference in a new issue