Skip to content

Commit

Permalink
feat: update omnilock bitcoin sign message (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
homura authored Jan 22, 2024
1 parent 66228d6 commit 028d28e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/honest-trainers-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ckb-lumos/common-scripts": minor
"@ckb-lumos/config-manager": minor
---

feat: omnilock bitcoin auth message is changed to `CKB (Bitcoin Layer) transaction: 0x`
7 changes: 2 additions & 5 deletions examples/misc/config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ const script = {
args: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
};

/* DEPRECATED: initialize config via env mainnet */
console.log("deprecated initialize", helpers.generateAddress(script));

/* initialize config via AGGRON testnet */
config.initializeConfig(config.predefined.AGGRON4);
console.log("testnet address is:", helpers.generateAddress(script));
console.log("testnet address is:", helpers.encodeToAddress(script));

/* initialize config via LINA testnet */
config.initializeConfig(config.predefined.LINA);
console.log("mainnet address is:", helpers.generateAddress(script));
console.log("mainnet address is:", helpers.encodeToAddress(script));
6 changes: 3 additions & 3 deletions packages/common-scripts/src/omnilock-bitcoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { bytes, BytesLike } from "@ckb-lumos/codec";
import { bech32 } from "bech32";
import bs58 from "bs58";

// https://github.com/XuJiandong/ckb-production-scripts/blob/f884d97963ad553b91bfcc992f68d1ad90f9b244/c/ckb_identity.h#L28
const BTC_PREFIX = "CKB (Bitcoin Layer-2) transaction: 0x";
// https://github.com/cryptape/omnilock/blob/9419b7795641da0ade25a04127e25d8a0b709077/c/ckb_identity.h#L28
const BTC_PREFIX = "CKB (Bitcoin Layer) transaction: 0x";

/**
* Decode bitcoin address to public key hash in bytes
Expand All @@ -28,7 +28,7 @@ export function decodeAddress(address: string): ArrayLike<number> {
}
} catch {
// https://bitcoin.design/guide/glossary/address/#taproot-address---p2tr
if (address.startsWith("bc1q")) {
if (address.startsWith("bc1p")) {
throw new Error("Taproot address is not supported yet.");
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/common-scripts/tests/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const charlesOmnilockInputs: Cell[] = [
capacity: "0x174876e800",
lock: {
codeHash:
"0xd83e7ec3ed31b24f7627af8d05d8da7a87fdf1afa120ef75a5c487464e8472aa",
"0x768f306681da232ceb0b94f436c5f813377179762a831c5ad8797bd4fd2d118d",
hashType: "data",
args: "0x00e3e0a82b199dceadb55e223c6e4b8e511d57d24900",
},
Expand All @@ -28,7 +28,7 @@ export const charlesOmnilockInputs: Cell[] = [
capacity: "0x174876e800",
lock: {
codeHash:
"0xd83e7ec3ed31b24f7627af8d05d8da7a87fdf1afa120ef75a5c487464e8472aa",
"0x768f306681da232ceb0b94f436c5f813377179762a831c5ad8797bd4fd2d118d",
hashType: "data",
args: "0x00e3e0a82b199dceadb55e223c6e4b8e511d57d24900",
},
Expand Down
2 changes: 1 addition & 1 deletion packages/config-manager/src/predefined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const AGGRON4 = createConfig({
"0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
HASH_TYPE: "type",
TX_HASH:
"0xb50ef6f2e9138f4dbca7d5280e10d29c1a65e60e8a574c009a2fa4e4107e0750",
"0x3d4296df1bd2cc2bd3f483f61ab7ebeac462a2f336f2b944168fe6ba5d81c014",
INDEX: "0x0",
DEP_TYPE: "code",
},
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/debugger/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function getDefaultConfig(): {
},
OMNILOCK: {
depType: "code",
path: path.join(__dirname, "../contracts/omni_lock_f884d979"),
path: path.join(__dirname, "../contracts/omni_lock_9419b77"),
},
DAO: {
depType: "code",
Expand Down

2 comments on commit 028d28e

@vercel
Copy link

@vercel vercel bot commented on 028d28e Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 New canary release: 0.0.0-canary-028d28e-20240122052135

npm install @ckb-lumos/[email protected]

Please sign in to comment.