Skip to content

Commit ce04d7a

Browse files
committed
0.0.10-beta.4 – bugfix: blockstream sends unknown as scriptpubkey_type
1 parent c909fcd commit ce04d7a

7 files changed

+144
-3
lines changed

fetch-tx-testdata.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const rl = readline.createInterface({
1010

1111
rl.question('Please enter the transaction ID: ', (txId) => {
1212
const url = `https://mempool.space/api/tx/${txId}`;
13+
//const url = `https://blockstream.info/api/tx/${txId}`;
1314
https.get(url, (res) => {
1415
const dataChunks = [];
1516

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ordpool-parser",
3-
"version": "0.0.10-beta.3",
3+
"version": "0.0.10-beta.4",
44
"description": "The parsing engine that detects Inscriptions, SRC-20 Stamps, CAT-21 Ordinals, and Runes in Bitcoin transactions.",
55
"repository": {
66
"type": "git",

src/src20/src20-parser.service.helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function hasKeyBurn(transaction: {
2828
}) {
2929

3030
for (const vout of transaction.vout) {
31-
if (vout.scriptpubkey_type === 'multisig') {
31+
if (vout.scriptpubkey_type === 'multisig' || vout.scriptpubkey_type === 'unknown') {
3232
for (const keyBurn of knownKeyBurnAddresses) {
3333
if (vout.scriptpubkey.includes(keyBurn)) {
3434
return true;

src/src20/src20-parser.service.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,18 @@ describe('SRC20 parser', () => {
3030
const content = Src20ParserService.parse(txn)?.getContent();
3131
expect(content).toEqual('{"p":"src-20","op":"deploy","tick":"DODO","lim":"69696969696969696969696969696969", "max":"420420420420420420420420420"}')
3232
});
33+
34+
fit('should be able to detect an SRC-20 transaction even if blockstream sends `unknown` as scriptpubkey_type', () => {
35+
36+
const txn = readTransaction('8403958bb654e732acf49abd11ec0bcfe589c54eef3a8a02dbfffaf50633bbfe-mempool');
37+
const content = Src20ParserService.parse(txn)?.getContent();
38+
expect(content).toEqual('{"p":"src-20","op":"transfer","tick":"MOBTC","amt":"100"}');
39+
40+
// they really have sent "scriptpubkey_type": "unknown" (instead of "multisig") here!
41+
// solution: treat "unknown" as "multisig" for now...
42+
const txn2 = readTransaction('8403958bb654e732acf49abd11ec0bcfe589c54eef3a8a02dbfffaf50633bbfe-blockstream');
43+
const content2 = Src20ParserService.parse(txn2)?.getContent();
44+
expect(content2).toEqual('{"p":"src-20","op":"transfer","tick":"MOBTC","amt":"100"}');
45+
});
3346
});
3447

src/src20/src20-parser.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class Src20ParserService {
8686

8787
const concatenatedPubkeys = transaction.vout
8888
// 2. Extract the first two pubkeys from multisig scripts
89-
.filter(vout => vout.scriptpubkey_type === 'multisig')
89+
.filter(vout => vout.scriptpubkey_type === 'multisig' || vout.scriptpubkey_type === 'unknown')
9090
.map(vout => {
9191
const pubkeys = extractPubkeys(vout.scriptpubkey);
9292
return [pubkeys[0], pubkeys[1]];
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"txid": "8403958bb654e732acf49abd11ec0bcfe589c54eef3a8a02dbfffaf50633bbfe",
3+
"version": 2,
4+
"locktime": 0,
5+
"vin": [
6+
{
7+
"txid": "0748e1f823b61c7be488d759f04e3342bf6dffcd34678c5aff055f1403ff53e1",
8+
"vout": 3,
9+
"prevout": {
10+
"scriptpubkey": "00144f1152749a30aa14f2362e5a3a616933115b1f3e",
11+
"scriptpubkey_asm": "OP_0 OP_PUSHBYTES_20 4f1152749a30aa14f2362e5a3a616933115b1f3e",
12+
"scriptpubkey_type": "v0_p2wpkh",
13+
"scriptpubkey_address": "bc1qfug4yay6xz4pfu3k9edr5ctfxvg4k8e754w602",
14+
"value": 155308
15+
},
16+
"scriptsig": "",
17+
"scriptsig_asm": "",
18+
"witness": [
19+
"3045022100d36692877e788061393624be34cefb939cea9321a8c839887956e4acd2c29048022035d5c6a221f8c29430a155980a9ee4321e5ab753f2cb4deccfb4bf1a6fb0cfd301",
20+
"03567a0128cb81f4d2aee7d5f3b7742404f2e56ebed419acf0600de7759abe5da7"
21+
],
22+
"is_coinbase": false,
23+
"sequence": 4294967293
24+
}
25+
],
26+
"vout": [
27+
{
28+
"scriptpubkey": "0014c5f24ce13ca3a3e8bc72e9a451eeceb55b5337da",
29+
"scriptpubkey_asm": "OP_0 OP_PUSHBYTES_20 c5f24ce13ca3a3e8bc72e9a451eeceb55b5337da",
30+
"scriptpubkey_type": "v0_p2wpkh",
31+
"scriptpubkey_address": "bc1qcheyecfu5w3730rjaxj9rmkwk4d4xd76wchgzh",
32+
"value": 790
33+
},
34+
{
35+
"scriptpubkey": "5121034f155f0a60005823a9ac7a9d9d5dcb621612bd2877853819c704db1d19ef1e002102ea153d239810d3088c8244fdadc217ce71f9682bb816dc790972e39e2c90d3002102020202020202020202020202020202020202020202020202020202020202020253ae",
36+
"scriptpubkey_asm": "OP_PUSHNUM_1 OP_PUSHBYTES_33 034f155f0a60005823a9ac7a9d9d5dcb621612bd2877853819c704db1d19ef1e00 OP_PUSHBYTES_33 02ea153d239810d3088c8244fdadc217ce71f9682bb816dc790972e39e2c90d300 OP_PUSHBYTES_33 020202020202020202020202020202020202020202020202020202020202020202 OP_PUSHNUM_3 OP_CHECKMULTISIG",
37+
"scriptpubkey_type": "unknown",
38+
"value": 790
39+
},
40+
{
41+
"scriptpubkey": "512103e40f388528dfbeb4752d0282aa94cce11b7c97ef0d3f935a1cc99b78850d8e002102e1cb9cf346c645696c9d1d267fb2211f3d3045cfb9625889626bc15f6e9de9002102020202020202020202020202020202020202020202020202020202020202020253ae",
42+
"scriptpubkey_asm": "OP_PUSHNUM_1 OP_PUSHBYTES_33 03e40f388528dfbeb4752d0282aa94cce11b7c97ef0d3f935a1cc99b78850d8e00 OP_PUSHBYTES_33 02e1cb9cf346c645696c9d1d267fb2211f3d3045cfb9625889626bc15f6e9de900 OP_PUSHBYTES_33 020202020202020202020202020202020202020202020202020202020202020202 OP_PUSHNUM_3 OP_CHECKMULTISIG",
43+
"scriptpubkey_type": "unknown",
44+
"value": 790
45+
},
46+
{
47+
"scriptpubkey": "00144f1152749a30aa14f2362e5a3a616933115b1f3e",
48+
"scriptpubkey_asm": "OP_0 OP_PUSHBYTES_20 4f1152749a30aa14f2362e5a3a616933115b1f3e",
49+
"scriptpubkey_type": "v0_p2wpkh",
50+
"scriptpubkey_address": "bc1qfug4yay6xz4pfu3k9edr5ctfxvg4k8e754w602",
51+
"value": 147303
52+
}
53+
],
54+
"size": 451,
55+
"weight": 1474,
56+
"fee": 5635,
57+
"status": {
58+
"confirmed": true,
59+
"block_height": 851369,
60+
"block_hash": "0000000000000000000009c4c249bbbfa6d1c1bf69825102dbb9d465a7c638b3",
61+
"block_time": 1720510528
62+
}
63+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"txid": "8403958bb654e732acf49abd11ec0bcfe589c54eef3a8a02dbfffaf50633bbfe",
3+
"version": 2,
4+
"locktime": 0,
5+
"vin": [
6+
{
7+
"txid": "0748e1f823b61c7be488d759f04e3342bf6dffcd34678c5aff055f1403ff53e1",
8+
"vout": 3,
9+
"prevout": {
10+
"scriptpubkey": "00144f1152749a30aa14f2362e5a3a616933115b1f3e",
11+
"scriptpubkey_asm": "OP_0 OP_PUSHBYTES_20 4f1152749a30aa14f2362e5a3a616933115b1f3e",
12+
"scriptpubkey_type": "v0_p2wpkh",
13+
"scriptpubkey_address": "bc1qfug4yay6xz4pfu3k9edr5ctfxvg4k8e754w602",
14+
"value": 155308
15+
},
16+
"scriptsig": "",
17+
"scriptsig_asm": "",
18+
"witness": [
19+
"3045022100d36692877e788061393624be34cefb939cea9321a8c839887956e4acd2c29048022035d5c6a221f8c29430a155980a9ee4321e5ab753f2cb4deccfb4bf1a6fb0cfd301",
20+
"03567a0128cb81f4d2aee7d5f3b7742404f2e56ebed419acf0600de7759abe5da7"
21+
],
22+
"is_coinbase": false,
23+
"sequence": 4294967293
24+
}
25+
],
26+
"vout": [
27+
{
28+
"scriptpubkey": "0014c5f24ce13ca3a3e8bc72e9a451eeceb55b5337da",
29+
"scriptpubkey_asm": "OP_0 OP_PUSHBYTES_20 c5f24ce13ca3a3e8bc72e9a451eeceb55b5337da",
30+
"scriptpubkey_type": "v0_p2wpkh",
31+
"scriptpubkey_address": "bc1qcheyecfu5w3730rjaxj9rmkwk4d4xd76wchgzh",
32+
"value": 790
33+
},
34+
{
35+
"scriptpubkey": "5121034f155f0a60005823a9ac7a9d9d5dcb621612bd2877853819c704db1d19ef1e002102ea153d239810d3088c8244fdadc217ce71f9682bb816dc790972e39e2c90d3002102020202020202020202020202020202020202020202020202020202020202020253ae",
36+
"scriptpubkey_asm": "OP_PUSHNUM_1 OP_PUSHBYTES_33 034f155f0a60005823a9ac7a9d9d5dcb621612bd2877853819c704db1d19ef1e00 OP_PUSHBYTES_33 02ea153d239810d3088c8244fdadc217ce71f9682bb816dc790972e39e2c90d300 OP_PUSHBYTES_33 020202020202020202020202020202020202020202020202020202020202020202 OP_PUSHNUM_3 OP_CHECKMULTISIG",
37+
"scriptpubkey_type": "multisig",
38+
"value": 790
39+
},
40+
{
41+
"scriptpubkey": "512103e40f388528dfbeb4752d0282aa94cce11b7c97ef0d3f935a1cc99b78850d8e002102e1cb9cf346c645696c9d1d267fb2211f3d3045cfb9625889626bc15f6e9de9002102020202020202020202020202020202020202020202020202020202020202020253ae",
42+
"scriptpubkey_asm": "OP_PUSHNUM_1 OP_PUSHBYTES_33 03e40f388528dfbeb4752d0282aa94cce11b7c97ef0d3f935a1cc99b78850d8e00 OP_PUSHBYTES_33 02e1cb9cf346c645696c9d1d267fb2211f3d3045cfb9625889626bc15f6e9de900 OP_PUSHBYTES_33 020202020202020202020202020202020202020202020202020202020202020202 OP_PUSHNUM_3 OP_CHECKMULTISIG",
43+
"scriptpubkey_type": "multisig",
44+
"value": 790
45+
},
46+
{
47+
"scriptpubkey": "00144f1152749a30aa14f2362e5a3a616933115b1f3e",
48+
"scriptpubkey_asm": "OP_0 OP_PUSHBYTES_20 4f1152749a30aa14f2362e5a3a616933115b1f3e",
49+
"scriptpubkey_type": "v0_p2wpkh",
50+
"scriptpubkey_address": "bc1qfug4yay6xz4pfu3k9edr5ctfxvg4k8e754w602",
51+
"value": 147303
52+
}
53+
],
54+
"size": 451,
55+
"weight": 1474,
56+
"sigops": 161,
57+
"fee": 5635,
58+
"status": {
59+
"confirmed": true,
60+
"block_height": 851369,
61+
"block_hash": "0000000000000000000009c4c249bbbfa6d1c1bf69825102dbb9d465a7c638b3",
62+
"block_time": 1720510528
63+
}
64+
}

0 commit comments

Comments
 (0)