Skip to content

Commit

Permalink
Merge pull request #468 from bob-collective/feat/check-mempool-tx-run…
Browse files Browse the repository at this point in the history
…e-pt2

chore: replace runestonejs with magiceden runestone
  • Loading branch information
gregdhill authored Jan 31, 2025
2 parents 59afafa + 01fba8c commit 9217101
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 40 deletions.
33 changes: 10 additions & 23 deletions sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gobob/bob-sdk",
"version": "3.1.3",
"version": "3.1.4",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
Expand Down Expand Up @@ -39,11 +39,11 @@
"yargs": "^17.5.1"
},
"dependencies": {
"@magiceden-oss/runestone-lib": "^1.0.2",
"@scure/base": "^1.1.7",
"@scure/btc-signer": "^1.3.2",
"bitcoin-address-validation": "^2.2.3",
"bitcoinjs-lib": "^6.1.6",
"ethers": "^6.13.2",
"runestone-js": "0.3.0"
"ethers": "^6.13.2"
}
}
21 changes: 11 additions & 10 deletions sdk/src/runes.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import * as bitcoin from 'bitcoinjs-lib';
import { EsploraClient } from './esplora';
// This implementation is based on ord 0.17.1, *use this as a reference only
import { Runestone } from 'runestone-js';
import { Cenotaph, RunestoneSpec, tryDecodeRunestone } from '@magiceden-oss/runestone-lib';

export function parseRunestone(tx: bitcoin.Transaction): Runestone | undefined {
for (const out of tx.outs) {
if (out.script[0] === bitcoin.opcodes.OP_RETURN && out.script[1] === bitcoin.opcodes.OP_13) {
// skip OP_RETURN OP_13 OP_PUSHBYTES
const pureOutputBuffer = out.script.subarray(3);
return Runestone.dechiper(pureOutputBuffer);
}
}
export function parseRunestone(tx: bitcoin.Transaction): RunestoneSpec | Cenotaph | null {
const rune = tryDecodeRunestone({
vout: tx.outs.map((out) => ({
scriptPubKey: {
hex: out.script.toString('hex'),
},
})),
});

return rune;
}

export async function getTxRunestone(esploraClient: EsploraClient, txid: string) {
Expand Down
8 changes: 4 additions & 4 deletions sdk/test/utxo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe('UTXO Tests', () => {
// TODO: Use a real P2SH-P2WPKH address
// TODO: Add the pubkey to allow spending from the outputs
// '3DFVKuT9Ft4rWpysAZ1bHpg55EBy1HVPcr',
// P2PKH: https://blockstream.info/address/1Kr6QSydW9bFQG1mXiPNNu6WpJGmUa9i1g
'1Kr6QSydW9bFQG1mXiPNNu6WpJGmUa9i1g',
// P2PKH: https://blockstream.info/address/1PM46U2c5LhkcQXnHwfwQU6V1y4F4L7Ct4
'1PM46U2c5LhkcQXnHwfwQU6V1y4F4L7Ct4',
// P2TR https://blockstream.info/address/bc1peqr5a5kfufvsl66444jm9y8qq0s87ph0zv4lfkcs7h40ew02uvsqkhjav0
'bc1peqr5a5kfufvsl66444jm9y8qq0s87ph0zv4lfkcs7h40ew02uvsqkhjav0',
];
Expand Down Expand Up @@ -304,8 +304,8 @@ describe('UTXO Tests', () => {
// P2SH-P2WPKH: https://blockstream.info/address/3DFVKuT9Ft4rWpysAZ1bHpg55EBy1HVPcr
// TODO: As above, add a correct P2SH-P2WPKH address with its pub key
// '3DFVKuT9Ft4rWpysAZ1bHpg55EBy1HVPcr',
// P2PKH: https://blockstream.info/address/1Kr6QSydW9bFQG1mXiPNNu6WpJGmUa9i1g
'1Kr6QSydW9bFQG1mXiPNNu6WpJGmUa9i1g',
// P2PKH: https://blockstream.info/address/1PM46U2c5LhkcQXnHwfwQU6V1y4F4L7Ct4
'1PM46U2c5LhkcQXnHwfwQU6V1y4F4L7Ct4',
// P2TR https://blockstream.info/address/bc1peqr5a5kfufvsl66444jm9y8qq0s87ph0zv4lfkcs7h40ew02uvsqkhjav0
'bc1peqr5a5kfufvsl66444jm9y8qq0s87ph0zv4lfkcs7h40ew02uvsqkhjav0',
];
Expand Down

0 comments on commit 9217101

Please sign in to comment.