Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useBCH.js
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | ) => { | ||||
configObj, | configObj, | ||||
); | ); | ||||
// update txBuilder object with outputs | // update txBuilder object with outputs | ||||
txBuilder = tokenTxOutputObj; | txBuilder = tokenTxOutputObj; | ||||
// sign the collated inputUtxos and build the raw tx hex | // sign the collated inputUtxos and build the raw tx hex | ||||
// returns the raw tx hex string | // returns the raw tx hex string | ||||
const rawTxHex = signAndBuildTx( | const rawTxHex = signAndBuildTx( | ||||
BCH, | |||||
tokenTxInputObj.inputXecUtxos, | tokenTxInputObj.inputXecUtxos, | ||||
txBuilder, | txBuilder, | ||||
wallet, | wallet, | ||||
); | ); | ||||
// Broadcast transaction to the network via the chronik client | // Broadcast transaction to the network via the chronik client | ||||
// sample chronik.broadcastTx() response: | // sample chronik.broadcastTx() response: | ||||
// {"txid":"0075130c9ecb342b5162bb1a8a870e69c935ea0c9b2353a967cda404401acf19"} | // {"txid":"0075130c9ecb342b5162bb1a8a870e69c935ea0c9b2353a967cda404401acf19"} | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | ) => { | ||||
// append the token input UTXOs to the array of XEC input UTXOs for signing | // append the token input UTXOs to the array of XEC input UTXOs for signing | ||||
const combinedInputUtxos = tokenTxInputObj.inputXecUtxos.concat( | const combinedInputUtxos = tokenTxInputObj.inputXecUtxos.concat( | ||||
tokenTxInputObj.inputTokenUtxos, | tokenTxInputObj.inputTokenUtxos, | ||||
); | ); | ||||
// sign the collated inputUtxos and build the raw tx hex | // sign the collated inputUtxos and build the raw tx hex | ||||
// returns the raw tx hex string | // returns the raw tx hex string | ||||
const rawTxHex = signAndBuildTx( | const rawTxHex = signAndBuildTx(combinedInputUtxos, txBuilder, wallet); | ||||
BCH, | |||||
combinedInputUtxos, | |||||
txBuilder, | |||||
wallet, | |||||
); | |||||
// Broadcast transaction to the network via the chronik client | // Broadcast transaction to the network via the chronik client | ||||
// sample chronik.broadcastTx() response: | // sample chronik.broadcastTx() response: | ||||
// {"txid":"0075130c9ecb342b5162bb1a8a870e69c935ea0c9b2353a967cda404401acf19"} | // {"txid":"0075130c9ecb342b5162bb1a8a870e69c935ea0c9b2353a967cda404401acf19"} | ||||
let broadcastResponse; | let broadcastResponse; | ||||
try { | try { | ||||
broadcastResponse = await chronik.broadcastTx( | broadcastResponse = await chronik.broadcastTx( | ||||
rawTxHex, | rawTxHex, | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | const burnToken = async (BCH, chronik, wallet, { tokenId, amount }) => { | ||||
// append the token input UTXOs to the array of XEC input UTXOs for signing | // append the token input UTXOs to the array of XEC input UTXOs for signing | ||||
const combinedInputUtxos = tokenTxInputObj.inputXecUtxos.concat( | const combinedInputUtxos = tokenTxInputObj.inputXecUtxos.concat( | ||||
tokenTxInputObj.inputTokenUtxos, | tokenTxInputObj.inputTokenUtxos, | ||||
); | ); | ||||
// sign the collated inputUtxos and build the raw tx hex | // sign the collated inputUtxos and build the raw tx hex | ||||
// returns the raw tx hex string | // returns the raw tx hex string | ||||
const rawTxHex = signAndBuildTx( | const rawTxHex = signAndBuildTx(combinedInputUtxos, txBuilder, wallet); | ||||
BCH, | |||||
combinedInputUtxos, | |||||
txBuilder, | |||||
wallet, | |||||
); | |||||
// Broadcast transaction to the network via the chronik client | // Broadcast transaction to the network via the chronik client | ||||
// sample chronik.broadcastTx() response: | // sample chronik.broadcastTx() response: | ||||
// {"txid":"0075130c9ecb342b5162bb1a8a870e69c935ea0c9b2353a967cda404401acf19"} | // {"txid":"0075130c9ecb342b5162bb1a8a870e69c935ea0c9b2353a967cda404401acf19"} | ||||
let broadcastResponse; | let broadcastResponse; | ||||
try { | try { | ||||
broadcastResponse = await chronik.broadcastTx( | broadcastResponse = await chronik.broadcastTx( | ||||
rawTxHex, | rawTxHex, | ||||
▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | ) => { | ||||
txInputObj.txFee, | txInputObj.txFee, | ||||
txBuilder, | txBuilder, | ||||
); | ); | ||||
txBuilder = txOutputObj; // update the local txBuilder with the generated tx outputs | txBuilder = txOutputObj; // update the local txBuilder with the generated tx outputs | ||||
// sign the collated inputUtxos and build the raw tx hex | // sign the collated inputUtxos and build the raw tx hex | ||||
// returns the raw tx hex string | // returns the raw tx hex string | ||||
const rawTxHex = signAndBuildTx( | const rawTxHex = signAndBuildTx( | ||||
BCH, | |||||
txInputObj.inputUtxos, | txInputObj.inputUtxos, | ||||
txBuilder, | txBuilder, | ||||
wallet, | wallet, | ||||
); | ); | ||||
// Broadcast transaction to the network via the chronik client | // Broadcast transaction to the network via the chronik client | ||||
// sample chronik.broadcastTx() response: | // sample chronik.broadcastTx() response: | ||||
// {"txid":"0075130c9ecb342b5162bb1a8a870e69c935ea0c9b2353a967cda404401acf19"} | // {"txid":"0075130c9ecb342b5162bb1a8a870e69c935ea0c9b2353a967cda404401acf19"} | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |