Signing transactions
Bitcoin
Before a transaction can be sent to the Bitcoin network, each input must be signed.
Threshold ECDSA
Canisters can sign transactions with threshold ECDSA through the sign_with_ecdsa
method.
The following snippet shows a simplified example of how to sign a Bitcoin transaction for the special case where all the inputs are referencing outpoints that are owned by own_address
and own_address
is a P2PKH
address.
- Motoko
- Rust
motoko/basic_bitcoin/src/basic_bitcoin/src/P2pkh.mo
loading...
rust/basic_bitcoin/src/p2pkh.rs
loading...
Threshold Schnorr
Canisters can sign transactions with threshold Schnorr through the sign_with_schnorr
method.
Signing P2TR key path transactions
- Motoko
- Rust
motoko/basic_bitcoin/src/basic_bitcoin/src/P2tr.mo
loading...
rust/basic_bitcoin/src/p2tr.rs
loading...
Signing P2TR script path transactions
- Motoko
- Rust
motoko/basic_bitcoin/src/basic_bitcoin/src/P2tr.mo
loading...
rust/basic_bitcoin/src/p2tr.rs
loading...