Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion modules/utxo-ord/src/inscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import { PreparedInscriptionRevealData } from '@bitgo/sdk-core';

const OPS = bscript.OPS;
const MAX_LENGTH_TAP_DATA_PUSH = 520;
// default "postage" amount
// https://github.com/ordinals/ord/blob/0.24.2/src/lib.rs#L149
const DEFAULT_POSTAGE_AMOUNT = BigInt(10_000);

/**
* The max size of an individual OP_PUSH in a Taproot script is 520 bytes. This
Expand Down Expand Up @@ -100,7 +103,7 @@ function getInscriptionRevealSize(
},
],
});
psbt.addOutput({ script: commitOutput, value: BigInt(10_000) });
psbt.addOutput({ script: commitOutput, value: DEFAULT_POSTAGE_AMOUNT });

psbt.signTaprootInput(
0,
Expand Down
9 changes: 5 additions & 4 deletions modules/utxo-ord/test/inscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function createCommitTransactionPsbt(commitAddress: string, walletKeys: utxolib.

commitTransactionPsbt.addOutput({
script: commitTransactionOutputScript,
value: BigInt(42),
value: BigInt(10_000),
});

const walletUnspent = testutil.mockWalletUnspent(networks.testnet, BigInt(20_000), { keys: walletKeys });
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('inscriptions', () => {
});
});

xdescribe('Inscription Reveal Data', () => {
describe('Inscription Reveal Data', () => {
it('should sign reveal transaction and validate reveal size', () => {
const walletKeys = testutil.getDefaultWalletKeys();
const inscriptionData = Buffer.from('And Desert You', 'ascii');
Expand All @@ -76,19 +76,20 @@ describe('inscriptions', () => {
);

const commitTransactionPsbt = createCommitTransactionPsbt(address, walletKeys);
// Use the commit address (P2TR) as recipient to match the output script size
// used in getInscriptionRevealSize estimation
const fullySignedRevealTransaction = inscriptions.signRevealTransaction(
walletKeys.user.privateKey as Buffer,
tapLeafScript,
address,
'2N9R3mMCv6UfVbWEUW3eXJgxDeg4SCUVsu9',
address,
commitTransactionPsbt.getUnsignedTx().toBuffer(),
networks.testnet
);

fullySignedRevealTransaction.finalizeTapInputWithSingleLeafScriptAndSignature(0);
const actualVirtualSize = fullySignedRevealTransaction.extractTransaction(true).virtualSize();

// TODO(BG-70861): figure out why size is slightly different and re-enable test
assert.strictEqual(revealTransactionVSize, actualVirtualSize);
});
});
Expand Down