Skip to content

Commit

Permalink
feat: serialize btc raw tx
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrxlz committed Apr 17, 2024
1 parent 2b40384 commit e561588
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/kos-sdk/src/chains/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,16 @@ impl BTC {
}
}

#[wasm_bindgen(js_name = "serializeTx")]
pub fn serialize_tx(tx: Transaction) -> Result<String, Error> {
match tx.data {
Some(TransactionRaw::Bitcoin(btc_tx)) => Ok(btc_tx.btc_serialize_hex()),
_ => Err(Error::InvalidTransaction(
"not a bitcoin transaction".to_string(),
)),
}
}

fn decode_magic(hex_magic: String) -> Result<Network, Error> {
let magic_bytes = hex::decode(hex_magic)?;
if magic_bytes.len() != 4 {
Expand Down

0 comments on commit e561588

Please sign in to comment.