Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
"ws": "^8.18.0"
},
"packageManager": "pnpm@10.8.1"
}
}
23 changes: 22 additions & 1 deletion packages/core/src/signer/btc/signerBtc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address } from "../../address/index.js";
import { bytesConcat, bytesFrom } from "../../bytes/index.js";
import { Transaction, TransactionLike, WitnessArgs } from "../../ckb/index.js";
import { KnownScript } from "../../client/index.js";
import { Client, KnownScript } from "../../client/index.js";
import { HexLike, hexFrom } from "../../hex/index.js";
import { numToBytes } from "../../num/index.js";
import { Signer, SignerSignType, SignerType } from "../signer/index.js";
Expand All @@ -14,6 +14,10 @@ import { btcEcdsaPublicKeyHash } from "./verify.js";
* @public
*/
export abstract class SignerBtc extends Signer {
constructor(client: Client) {
super(client);
}

get type(): SignerType {
return SignerType.BTC;
}
Expand Down Expand Up @@ -123,4 +127,21 @@ export abstract class SignerBtc extends Signer {
tx.setWitnessArgsAt(info.position, witness);
return tx;
}

/**
* Signs a Partially Signed Bitcoin Transaction (PSBT).
*
* @param psbtHex - The hex string of PSBT to sign
* @returns A promise that resolves to the signed PSBT hex string
* @todo Add support for Taproot signing options (useTweakedSigner, etc.)
*/
abstract signPsbt(psbtHex: string): Promise<string>;

/**
* Broadcasts a signed PSBT to the Bitcoin network.
*
* @param psbtHex - The hex string of signed PSBT to broadcast
* @returns A promise that resolves to the transaction ID
*/
abstract pushPsbt(psbtHex: string): Promise<string>;
}
8 changes: 8 additions & 0 deletions packages/core/src/signer/btc/signerBtcPublicKeyReadonly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ export class SignerBtcPublicKeyReadonly extends SignerBtc {
async getBtcPublicKey(): Promise<Hex> {
return this.publicKey;
}

async signPsbt(_: string): Promise<string> {
throw new Error("Read-only signer does not support signPsbt");
}

async pushPsbt(_: string): Promise<string> {
throw new Error("Read-only signer does not support pushPsbt");
}
}
2 changes: 2 additions & 0 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"@lit/react": "^1.0.5",
"@uiw/react-json-view": "2.0.0-alpha.30",
"bitcoinjs-lib": "6.1.6",
"lucide-react": "^0.427.0",
"next": "14.2.10",
"react": "^18",
Expand All @@ -25,6 +26,7 @@
"devDependencies": {
"@ckb-ccc/connector-react": "workspace:*",
"@ckb-ccc/lumos-patches": "workspace:*",
"@ckb-ccc/rgbpp": "workspace:*",
"@ckb-ccc/ssri": "workspace:*",
"@ckb-ccc/udt": "workspace:*",
"@ckb-lumos/ckb-indexer": "^0.24.0-next.1",
Expand Down
Loading