diff --git a/.changeset/flat-feet-fold.md b/.changeset/flat-feet-fold.md new file mode 100644 index 000000000..7b2ce244d --- /dev/null +++ b/.changeset/flat-feet-fold.md @@ -0,0 +1,5 @@ +--- +"@ckb-lumos/debugger": minor +--- + +feat: update default ckb-debugger version to 0.112 diff --git a/.changeset/gold-seals-pretend.md b/.changeset/gold-seals-pretend.md new file mode 100644 index 000000000..2ec1ce9d8 --- /dev/null +++ b/.changeset/gold-seals-pretend.md @@ -0,0 +1,5 @@ +--- +"@ckb-lumos/common-scripts": minor +--- + +feat: supported bitcoin auth in omnilock diff --git a/examples/misc-nodejs/package.json b/examples/misc-nodejs/package.json new file mode 100644 index 000000000..df43f2f4c --- /dev/null +++ b/examples/misc-nodejs/package.json @@ -0,0 +1,10 @@ +{ + "name": "@lumos-example/misc", + "private": true, + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@ckb-lumos/lumos": "canary", + "@ckb-lumos/debugger": "canary" + } +} diff --git a/examples/misc-nodejs/verify-sig-via-debugger.ts b/examples/misc-nodejs/verify-sig-via-debugger.ts new file mode 100644 index 000000000..4d7c1552e --- /dev/null +++ b/examples/misc-nodejs/verify-sig-via-debugger.ts @@ -0,0 +1,64 @@ +import { randomBytes } from "crypto"; +import { config, hd, Script } from "@ckb-lumos/lumos"; +import { CKBDebuggerDownloader, createTestContext, getDefaultConfig } from "@ckb-lumos/debugger"; +import { TransactionSkeleton } from "@ckb-lumos/lumos/helpers"; +import { common } from "@ckb-lumos/lumos/common-scripts"; +import { blockchain, bytes } from "@ckb-lumos/lumos/codec"; +import { computeScriptHash } from "@ckb-lumos/lumos/utils"; +import { mockOutPoint } from "@ckb-lumos/debugger/lib/context"; + +const context = createTestContext(getDefaultConfig()); +const lumosConfig = { PREFIX: "ckt", SCRIPTS: context.scriptConfigs }; +config.initializeConfig(lumosConfig); + +const privateKey = bytes.hexify(randomBytes(32)); + +async function main() { + await new CKBDebuggerDownloader().downloadIfNotExists(); + + const txSkeleton = TransactionSkeleton().asMutable(); + const lock: Script = { + codeHash: context.scriptConfigs.SECP256K1_BLAKE160.CODE_HASH, + hashType: context.scriptConfigs.SECP256K1_BLAKE160.HASH_TYPE, + args: hd.key.privateKeyToBlake160(privateKey), + }; + + await common.setupInputCell(txSkeleton, { + cellOutput: { capacity: "0x123123123", lock: lock }, + data: "0x", + outPoint: mockOutPoint(), + }); + + txSkeleton.update("cellDeps", (cellDeps) => + cellDeps.push({ + depType: context.scriptConfigs.SECP256K1_BLAKE160.DEP_TYPE, + outPoint: { + txHash: context.scriptConfigs.SECP256K1_BLAKE160.TX_HASH, + index: context.scriptConfigs.SECP256K1_BLAKE160.INDEX, + }, + }) + ); + + common.prepareSigningEntries(txSkeleton, { config: lumosConfig }); + const message = txSkeleton.get("signingEntries").get(0)!.message; + const sig = hd.key.signRecoverable(message, privateKey); + txSkeleton.update("witnesses", (witnesses) => + witnesses.update(0, (witness) => { + const unsigned = blockchain.WitnessArgs.unpack(witness!); + unsigned.lock = sig; + return bytes.hexify(blockchain.WitnessArgs.pack(unsigned)); + }) + ); + + const result = await context.executor.execute(txSkeleton, { + scriptHash: computeScriptHash(lock), + scriptGroupType: "lock", + }); + + console.assert(result.code === 0); + + console.log("Cycles consumed", result.cycles); + console.log(result.message); +} + +main(); diff --git a/examples/omni-lock-metamask/README.md b/examples/omni-lock-metamask/README.md index e8e9b4337..3f6004df5 100644 --- a/examples/omni-lock-metamask/README.md +++ b/examples/omni-lock-metamask/README.md @@ -1,8 +1,8 @@ # Lumos Works with MetaMask Nervos maintains a powerful lock -called [Omni Lock](https://github.com/XuJiandong/docs-bank/blob/master/omni_lock.md) (previously named RC lock), which -can use MetaMask as a signer. This example will show how to use Lumos to send a transaction using Omni lock and MetaMask +called [Omnilock](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0042-omnilock/0042-omnilock.md) (previously named RC lock), which +can use MetaMask as a signer. This example will show how to use Lumos to send a transaction using Omnilock and MetaMask ## Quick Start @@ -17,6 +17,6 @@ npm start ## Links -- [MetaMask](https://metamask.io/) - A crpto wallet +- [MetaMask](https://metamask.io/) - A cryptocurrency wallet - [Nervos Faucet](https://faucet.nervos.org/) - Claim Nervos testnet CKB -- [Omni lock](https://github.com/XuJiandong/docs-bank/blob/master/omni_lock.md) - Omni lock intro +- [Omnilock](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0042-omnilock/0042-omnilock.md) - Omnilock intro diff --git a/examples/omni-lock-secp256k1-blake160/README.md b/examples/omni-lock-secp256k1-blake160/README.md index db18e25ee..609718841 100644 --- a/examples/omni-lock-secp256k1-blake160/README.md +++ b/examples/omni-lock-secp256k1-blake160/README.md @@ -1,8 +1,8 @@ # Lumos & Omnilock secp256k1_blake160 Nervos maintains a powerful lock -called [Omni Lock](https://github.com/XuJiandong/docs-bank/blob/master/omni_lock.md) (previously named RC lock), which -can use private key as a signer. This example will show how to use Lumos to send a transaction using Omni lock +called [Omnilock](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0042-omnilock/0042-omnilock.md) (previously named RC lock), which +can use private key as a signer. This example will show how to use Lumos to send a transaction using Omnilock ## Quick Start @@ -17,4 +17,4 @@ npm start ## Links - [Nervos Faucet](https://faucet.nervos.org/) - Claim Nervos testnet CKB -- [Omni lock](https://github.com/XuJiandong/docs-bank/blob/master/omni_lock.md) - Omni lock intro +- [Omnilock](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0042-omnilock/0042-omnilock.md) - Omnilock intro diff --git a/examples/omni-lock-unisat/README.md b/examples/omni-lock-unisat/README.md new file mode 100644 index 000000000..1be68d270 --- /dev/null +++ b/examples/omni-lock-unisat/README.md @@ -0,0 +1,21 @@ +# Lumos Works with UniSat + +Nervos maintains a powerful lock +called [Omnilock](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0042-omnilock/0042-omnilock.md) (previously named RC lock), which +can use MetaMask as a signer. This example will show how to use Lumos to send a transaction using Omnilock and MetaMask + +## Quick Start + +> we should [build](..) Lumos project first before we start this example + +``` +npm run build +cd examples/omni-lock- +npm start +``` + +## Links + +- [MetaMask](https://unisat.io/) - A crypto wallet for Bitcoin +- [Nervos Faucet](https://faucet.nervos.org/) - Claim Nervos testnet CKB +- [Omnilock](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0042-omnilock/0042-omnilock.md) - Omnilock intro diff --git a/examples/omni-lock-unisat/index.html b/examples/omni-lock-unisat/index.html new file mode 100644 index 000000000..a243ae789 --- /dev/null +++ b/examples/omni-lock-unisat/index.html @@ -0,0 +1,13 @@ + + +
+ + + +