Skip to content

Commit

Permalink
added ops transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
kcw-grunt committed Jan 7, 2024
1 parent b006f64 commit 2593b39
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions BRWallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,36 @@ BRTransaction *BRWalletCreateTransaction(BRWallet *wallet, uint64_t amount, cons
return BRWalletCreateTxForOutputs(wallet, &o, 1);
}

// returns an unsigned transaction that sends the specified amount from the wallet to the given address
// result must be freed by calling BRTransactionFree()
BRTransaction *BRWalletCreateOpsTransaction(BRWallet *wallet,
uint64_t amount,
const char *addr,
uint64_t opsFee,
const char *opsAddr) {

BRTxOutput mainOutput = BR_TX_OUTPUT_NONE;
BRTxOutput opsOutput = BR_TX_OUTPUT_NONE;

assert(wallet != NULL);
assert(amount > 0);
assert(addr != NULL && BRAddressIsValid(addr));
mainOutput.amount = amount;
BRTxOutputSetAddress(&mainOutput, addr);

assert(wallet != NULL);
assert(opsFee > 0);
assert(opsAddr != NULL && BRAddressIsValid(opsAddr));
opsOutput.amount = opsFee;
BRTxOutputSetAddress(&opsOutput, opsAddr);

BRTxOutput outputs[2];
outputs[0] = opsOutput;
outputs[1] = mainOutput;

return BRWalletCreateTxForOutputs(wallet, outputs, 2);
}

/// Description:
/// returns an unsigned transaction that satisifes the given transaction outputs
/// result must be freed by calling BRTransactionFree()
Expand Down
2 changes: 1 addition & 1 deletion BRWallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void BRWalletSetFeePerKb(BRWallet *wallet, uint64_t feePerKb);

// returns an unsigned transaction that sends the specified amount from the wallet to the given address
// result must be freed using BRTransactionFree()
BRTransaction *BRWalletCreateTransaction(BRWallet *wallet, uint64_t amount, const char *addr);
BRTransaction *BRWalletCreateOpsTransaction(BRWallet *wallet, uint64_t amount, const char *addr, uint64_t opsFee, const char *opsAddr);

// returns an unsigned transaction that satisifes the given transaction outputs
// result must be freed using BRTransactionFree()
Expand Down

0 comments on commit 2593b39

Please sign in to comment.