Skip to content

Commit 7962c68

Browse files
Merge pull request #7899 from BitGo/BTC-2936.utxo-ord-fixes
feat(utxo-ord): improve inscription reveal and postage handling
2 parents 54e2595 + 4d4bae3 commit 7962c68

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

modules/utxo-ord/src/inscriptions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import { PreparedInscriptionRevealData } from '@bitgo/sdk-core';
2121

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

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

105108
psbt.signTaprootInput(
106109
0,

modules/utxo-ord/test/inscription.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function createCommitTransactionPsbt(commitAddress: string, walletKeys: utxolib.
99

1010
commitTransactionPsbt.addOutput({
1111
script: commitTransactionOutputScript,
12-
value: BigInt(42),
12+
value: BigInt(10_000),
1313
});
1414

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

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

7878
const commitTransactionPsbt = createCommitTransactionPsbt(address, walletKeys);
79+
// Use the commit address (P2TR) as recipient to match the output script size
80+
// used in getInscriptionRevealSize estimation
7981
const fullySignedRevealTransaction = inscriptions.signRevealTransaction(
8082
walletKeys.user.privateKey as Buffer,
8183
tapLeafScript,
8284
address,
83-
'2N9R3mMCv6UfVbWEUW3eXJgxDeg4SCUVsu9',
85+
address,
8486
commitTransactionPsbt.getUnsignedTx().toBuffer(),
8587
networks.testnet
8688
);
8789

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

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

0 commit comments

Comments
 (0)