Skip to content

Commit

Permalink
Merge pull request #359 from zed-wong/patch-1
Browse files Browse the repository at this point in the history
Fix memo in withdrawal example
  • Loading branch information
hundredark authored Nov 28, 2024
2 parents 147e2c9 + 3821ec4 commit 402300f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions example/safe_withdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const keystore = require('../keystore.json');

const withdrawal_asset_id = 'b91e18ff-a9ae-3dc7-8679-e935d9a4b34b';
const withdrawal_amount = '1';
const withdrawal_memo = 'memo';
const withdrawal_destination = '';
const spendPrivateKey = '';

Expand Down Expand Up @@ -44,6 +45,7 @@ const main = async () => {
{
amount: withdrawal_amount,
destination: withdrawal_destination,
tag: withdrawal_memo,
},
];
const { utxos, change } = getUnspentOutputsForRecipients(outputs, recipients);
Expand All @@ -63,7 +65,7 @@ const main = async () => {
})),
);
// spare the 0 inedx for withdrawal output, withdrawal output doesnt need ghost key
const tx = buildSafeTransaction(utxos, recipients, [undefined, ...ghosts], 'withdrawal-memo');
const tx = buildSafeTransaction(utxos, recipients, [undefined, ...ghosts], 'mainnet-transaction-extra');
console.log(tx);
const raw = encodeSafeTransaction(tx);
const ref = blake3Hash(Buffer.from(raw, 'hex')).toString('hex');
Expand All @@ -84,7 +86,7 @@ const main = async () => {
index: i,
})),
);
const feeTx = buildSafeTransaction(feeUtxos, feeRecipients, feeGhosts, 'withdrawal-fee-memo', [ref]);
const feeTx = buildSafeTransaction(feeUtxos, feeRecipients, feeGhosts, 'mainnet-fee-transaction-extra', [ref]);
console.log(feeTx);
const feeRaw = encodeSafeTransaction(feeTx);
console.log(feeRaw);
Expand Down Expand Up @@ -130,6 +132,7 @@ const main = async () => {
{
amount: withdrawal_amount,
destination: withdrawal_destination,
tag: withdrawal_memo,
},
// fee output
buildSafeTransactionRecipient([MixinCashier], 1, fee.amount),
Expand All @@ -151,7 +154,7 @@ const main = async () => {
})),
);
// spare the 0 inedx for withdrawal output, withdrawal output doesnt need ghost key
const tx = buildSafeTransaction(utxos, recipients, [undefined, ...ghosts], 'withdrawal-memo');
const tx = buildSafeTransaction(utxos, recipients, [undefined, ...ghosts], 'mainnet-transaction-extra');
console.log(tx);
const raw = encodeSafeTransaction(tx);

Expand Down

0 comments on commit 402300f

Please sign in to comment.