Skip to content

Commit

Permalink
0.24.0
Browse files Browse the repository at this point in the history
breaking change: use destructured parameters in txn helpers
  • Loading branch information
jcramer committed Jan 31, 2020
1 parent 3be87b9 commit 58a1257
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 101 deletions.
2 changes: 1 addition & 1 deletion examples/8-send-token-p2sh-frozen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import { BitboxNetwork, SlpBalancesResult, Slp, TransactionHelpers, Utils } from
inputUtxos.length // this many times since we swept inputs from p2sh address

// Build an unsigned transaction
let unsignedTxnHex = helpers.simpleTokenSend(tokenId, sendAmountsBN, inputUtxos, tokenReceiverAddress, bchChangeReceiverAddress, [], extraFee);
let unsignedTxnHex = helpers.simpleTokenSend({ tokenId, sendAmounts: sendAmountsBN, inputUtxos, tokenReceiverAddresses: tokenReceiverAddress, changeReceiverAddress: bchChangeReceiverAddress, extraFee });
unsignedTxnHex = helpers.enableInputsCLTV(unsignedTxnHex);
unsignedTxnHex = helpers.setTxnLocktime(unsignedTxnHex, locktime);

Expand Down
2 changes: 1 addition & 1 deletion examples/9-send-token-p2sh-multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import { BitboxNetwork, SlpBalancesResult, Slp, TransactionHelpers } from '../in
inputUtxos.length // this many times since we swept inputs from p2sh address

// 7) Build an unsigned transaction
let unsignedTxnHex = helpers.simpleTokenSend(tokenId, sendAmounts, inputUtxos, tokenReceiverAddress, bchChangeReceiverAddress, [], extraFee);
let unsignedTxnHex = helpers.simpleTokenSend({ tokenId, sendAmounts, inputUtxos, tokenReceiverAddresses: tokenReceiverAddress, changeReceiverAddress: bchChangeReceiverAddress, extraFee });

// 8) Build scriptSigs for all intputs
let redeemData = helpers.build_P2SH_multisig_redeem_data(2, [pubkey_signer_1, pubkey_signer_2]);
Expand Down
14 changes: 7 additions & 7 deletions lib/bitboxnetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class BitboxNetwork implements SlpValidator {

// Sent SLP tokens to a single output address with change handled (Warning: Sweeps all BCH/SLP UTXOs for the funding address)
async simpleTokenSend(tokenId: string, sendAmounts: BigNumber|BigNumber[], inputUtxos: SlpAddressUtxoResult[], tokenReceiverAddresses: string|string[], changeReceiverAddress: string, requiredNonTokenOutputs: { satoshis: number, receiverAddress: string }[] = []) {
let txHex = this.txnHelpers.simpleTokenSend(tokenId, sendAmounts, inputUtxos, tokenReceiverAddresses, changeReceiverAddress, requiredNonTokenOutputs);
let txHex = this.txnHelpers.simpleTokenSend({tokenId, sendAmounts, inputUtxos, tokenReceiverAddresses, changeReceiverAddress, requiredNonTokenOutputs});

if(!inputUtxos.every(i => typeof i.wif === "string"))
throw Error("The BitboxNetwork version of this method requires a private key WIF be provided with each input. If you want more control over the signing process use Slp.simpleTokenSend() to get the unsigned transaction, then after the transaction is signed you can use BitboxNetwork.sendTx()")
Expand All @@ -128,34 +128,34 @@ export class BitboxNetwork implements SlpValidator {
}

async simpleBchSend(sendAmounts: BigNumber|BigNumber[], inputUtxos: SlpAddressUtxoResult[], bchReceiverAddresses: string|string[], changeReceiverAddress: string) {
let genesisTxHex = this.txnHelpers.simpleBchSend(sendAmounts, inputUtxos, bchReceiverAddresses, changeReceiverAddress);
let genesisTxHex = this.txnHelpers.simpleBchSend({sendAmounts, inputUtxos, bchReceiverAddresses, changeReceiverAddress});
return await this.sendTx(genesisTxHex);
}

async simpleTokenGenesis(tokenName: string, tokenTicker: string, tokenAmount: BigNumber, documentUri: string|null, documentHash: Buffer|null, decimals: number, tokenReceiverAddress: string, batonReceiverAddress: string, bchChangeReceiverAddress: string, inputUtxos: SlpAddressUtxoResult[]) {
let genesisTxHex = this.txnHelpers.simpleTokenGenesis(tokenName, tokenTicker, tokenAmount, documentUri, documentHash, decimals, tokenReceiverAddress, batonReceiverAddress, bchChangeReceiverAddress, inputUtxos);
let genesisTxHex = this.txnHelpers.simpleTokenGenesis({tokenName, tokenTicker, tokenAmount, documentUri, documentHash, decimals, tokenReceiverAddress, batonReceiverAddress, bchChangeReceiverAddress, inputUtxos});
return await this.sendTx(genesisTxHex);
}

async simpleNFT1ParentGenesis(tokenName: string, tokenTicker: string, tokenAmount: BigNumber, documentUri: string|null, documentHash: Buffer|null, tokenReceiverAddress: string, batonReceiverAddress: string, bchChangeReceiverAddress: string, inputUtxos: SlpAddressUtxoResult[], decimals=0) {
let genesisTxHex = this.txnHelpers.simpleNFT1ParentGenesis(tokenName, tokenTicker, tokenAmount, documentUri, documentHash, tokenReceiverAddress, batonReceiverAddress, bchChangeReceiverAddress, inputUtxos, decimals);
let genesisTxHex = this.txnHelpers.simpleNFT1ParentGenesis({tokenName, tokenTicker, tokenAmount, documentUri, documentHash, tokenReceiverAddress, batonReceiverAddress, bchChangeReceiverAddress, inputUtxos, decimals});
return await this.sendTx(genesisTxHex);
}

async simpleNFT1ChildGenesis(nft1GroupId: string, tokenName: string, tokenTicker: string, documentUri: string|null, documentHash: Buffer|null, tokenReceiverAddress: string, bchChangeReceiverAddress: string, inputUtxos: SlpAddressUtxoResult[], allowBurnAnyAmount=false) {
let genesisTxHex = this.txnHelpers.simpleNFT1ChildGenesis(nft1GroupId, tokenName, tokenTicker, documentUri, documentHash, tokenReceiverAddress, bchChangeReceiverAddress, inputUtxos, allowBurnAnyAmount);
let genesisTxHex = this.txnHelpers.simpleNFT1ChildGenesis({nft1GroupId, tokenName, tokenTicker, documentUri, documentHash, tokenReceiverAddress, bchChangeReceiverAddress, inputUtxos, allowBurnAnyAmount});
return await this.sendTx(genesisTxHex);
}

// Sent SLP tokens to a single output address with change handled (Warning: Sweeps all BCH/SLP UTXOs for the funding address)
async simpleTokenMint(tokenId: string, mintAmount: BigNumber, inputUtxos: SlpAddressUtxoResult[], tokenReceiverAddress: string, batonReceiverAddress: string, changeReceiverAddress: string) {
let txHex = this.txnHelpers.simpleTokenMint(tokenId, mintAmount, inputUtxos, tokenReceiverAddress, batonReceiverAddress, changeReceiverAddress);
let txHex = this.txnHelpers.simpleTokenMint({tokenId, mintAmount, inputUtxos, tokenReceiverAddress, batonReceiverAddress, changeReceiverAddress});
return await this.sendTx(txHex);
}

// Burn a precise quantity of SLP tokens with remaining tokens (change) sent to a single output address (Warning: Sweeps all BCH/SLP UTXOs for the funding address)
async simpleTokenBurn(tokenId: string, burnAmount: BigNumber, inputUtxos: SlpAddressUtxoResult[], changeReceiverAddress: string) {
let txHex = this.txnHelpers.simpleTokenBurn(tokenId, burnAmount, inputUtxos, changeReceiverAddress);
let txHex = this.txnHelpers.simpleTokenBurn({tokenId, burnAmount, inputUtxos, changeReceiverAddress});
return await this.sendTx(txHex);
}

Expand Down
Loading

0 comments on commit 58a1257

Please sign in to comment.