Skip to content

Commit

Permalink
docs: add tasks for BTC ecosystem (#1218)
Browse files Browse the repository at this point in the history
* docs: update btc readme

* docs: add  tasks for BTC ecosystem

* refactor: remove btc dir

* refactor: rename BTC to btc
  • Loading branch information
jasonandjay authored Dec 13, 2024
1 parent f9b102c commit ea7b1dc
Show file tree
Hide file tree
Showing 49 changed files with 360 additions and 340 deletions.
33 changes: 0 additions & 33 deletions BTC/Advanced/OP_CAT/example/index.js

This file was deleted.

75 changes: 0 additions & 75 deletions BTC/Advanced/Psbt/rawParsePSBT.js

This file was deleted.

105 changes: 0 additions & 105 deletions BTC/README-ES.md

This file was deleted.

83 changes: 0 additions & 83 deletions BTC/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions btc/Advanced/OP_CAT/example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const bitcoin = require('bitcoinjs-lib');

// 创建一个包含 OP_CAT 的脚本
function createScript() {
// 连接的目标结果
const target = Buffer.from('HelloWorld');

const script = bitcoin.script.compile([
bitcoin.opcodes.OP_DUP,
bitcoin.opcodes.OP_HASH160,
Buffer.from('...'), // 使用适当的公钥哈希
bitcoin.opcodes.OP_EQUALVERIFY,
bitcoin.opcodes.OP_CHECKSIG,
// 连接两个字符串
Buffer.from('Hello'), // 第一个元素
Buffer.from('World'), // 第二个元素
bitcoin.opcodes.OP_CAT, // 连接操作,必须在两个字符串之后
target, // 连接后的目标结果
bitcoin.opcodes.OP_EQUAL, // 验证连接结果是否等于 'HelloWorld'
]);

return script;
}

// 创建和打印 P2SH 地址
function createP2SHAddress() {
const script = createScript();
const { address } = bitcoin.payments.p2sh({ redeem: { output: script, network: bitcoin.networks.bitcoin } });

console.log('P2SH Address:', address);
}

createP2SHAddress();
File renamed without changes.
Loading

0 comments on commit ea7b1dc

Please sign in to comment.