Skip to content

Commit

Permalink
feat: specify derivation path when signing with commit tx
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Sep 6, 2024
1 parent 4689a95 commit ac49a3c
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "ord-rs"
categories = ["cryptography::cryptocurrencies"]
license = "MIT"
version = "0.2.1"
version = "0.2.2"
authors = ["Finity Technologies"]
description = "A library for working with Ordinal inscriptions."
repository = "https://github.com/bitfinity-network/ord-rs"
Expand Down
1 change: 1 addition & 0 deletions examples/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async fn main() -> anyhow::Result<()> {
SignCommitTransactionArgs {
inputs,
txin_script_pubkey: sender_address.script_pubkey(),
derivation_path: None,
},
)
.await?;
Expand Down
1 change: 1 addition & 0 deletions examples/etch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ async fn main() -> anyhow::Result<()> {
SignCommitTransactionArgs {
inputs,
txin_script_pubkey: sender_address.script_pubkey(),
derivation_path: None,
},
)
.await?;
Expand Down
1 change: 1 addition & 0 deletions examples/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ async fn main() -> anyhow::Result<()> {
SignCommitTransactionArgs {
inputs,
txin_script_pubkey: sender_address.script_pubkey(),
derivation_path: None,
},
)
.await?;
Expand Down
1 change: 1 addition & 0 deletions examples/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ async fn main() -> anyhow::Result<()> {
SignCommitTransactionArgs {
inputs,
txin_script_pubkey: sender_address.script_pubkey(),
derivation_path: None,
},
)
.await?;
Expand Down
5 changes: 5 additions & 0 deletions src/wallet/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ pub struct SignCommitTransactionArgs {
pub inputs: Vec<Utxo>,
/// Script pubkey of the inputs
pub txin_script_pubkey: ScriptBuf,
/// Script pubkey of the inputs
pub derivation_path: Option<DerivationPath>,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -344,6 +346,7 @@ impl OrdTransactionBuilder {
&args.inputs,
unsigned_tx,
&args.txin_script_pubkey,
&args.derivation_path.unwrap_or_default(),
)
.await
}
Expand Down Expand Up @@ -605,6 +608,7 @@ mod test {
let sign_args = SignCommitTransactionArgs {
inputs,
txin_script_pubkey: address.script_pubkey(),
derivation_path: None,
};
let tx = builder
.sign_commit_transaction(tx_result.unsigned_tx, sign_args)
Expand Down Expand Up @@ -718,6 +722,7 @@ mod test {
let sign_args = SignCommitTransactionArgs {
inputs,
txin_script_pubkey: address.script_pubkey(),
derivation_path: None,
};
let tx = builder
.sign_commit_transaction(tx_result.unsigned_tx, sign_args)
Expand Down
1 change: 1 addition & 0 deletions src/wallet/builder/rune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ mod tests {
let sign_args = SignCommitTransactionArgs {
inputs,
txin_script_pubkey: address.script_pubkey(),
derivation_path: None,
};
let tx = builder
.sign_commit_transaction(tx_result.unsigned_tx, sign_args)
Expand Down
6 changes: 5 additions & 1 deletion src/wallet/builder/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ impl Wallet {
inputs: &[Utxo],
transaction: Transaction,
txin_script: &ScriptBuf,
derivation_path: &DerivationPath,
) -> OrdResult<Transaction> {
self.sign_ecdsa(
own_pubkey,
inputs,
transaction,
txin_script,
TransactionType::Commit,
derivation_path,
)
.await
}
Expand All @@ -143,6 +145,7 @@ impl Wallet {
transaction,
redeem_script,
TransactionType::Reveal,
&DerivationPath::default(),
)
.await
}
Expand Down Expand Up @@ -285,6 +288,7 @@ impl Wallet {
transaction: Transaction,
script: &ScriptBuf,
transaction_type: TransactionType,
derivation_path: &DerivationPath,
) -> OrdResult<Transaction> {
let mut hash = SighashCache::new(transaction.clone());
for (index, input) in utxos.iter().enumerate() {
Expand All @@ -306,7 +310,7 @@ impl Wallet {
let message = Message::from(sighash);
let signature = self
.signer
.sign_with_ecdsa(message, &DerivationPath::default())
.sign_with_ecdsa(message, derivation_path)
.await?;

// append witness
Expand Down

0 comments on commit ac49a3c

Please sign in to comment.