-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add tasks for BTC ecosystem (#1218)
* docs: update btc readme * docs: add tasks for BTC ecosystem * refactor: remove btc dir * refactor: rename BTC to btc
- Loading branch information
1 parent
f9b102c
commit ea7b1dc
Showing
49 changed files
with
360 additions
and
340 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.