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
9 changes: 6 additions & 3 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ dependencies = [
"bincode",
"bitcoin",
"getrandom 0.2.16",
"hex-conservative 1.0.0",
"hex-conservative 1.1.0",
"rand",
"rand_chacha",
"secp256k1-zkp",
Expand Down Expand Up @@ -293,9 +293,12 @@ dependencies = [

[[package]]
name = "hex-conservative"
version = "1.0.0"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ee770c000993d17c185713463d5ebfbd1af9afae4c17cc295640104383bfbf0"
checksum = "a7289f6b628ce69fb1a371d0fdcf8ff38cd93ec00e3010eb055d1e044998c8d1"
dependencies = [
"arrayvec",
]

[[package]]
name = "hex_lit"
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ serde_json = { version = "1.0", optional = true }
actual-serde = { package = "serde", version = "1.0.103", features = [
"derive",
], optional = true }
hex-conservative = "1.0.0"
hex = { package = "hex-conservative", version = "1.1.0" }


[target.wasm32-unknown-unknown.dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions elementsd-tests/src/pset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ extern crate rand;
use crate::{setup, Call};

use bitcoin::{self, Address, Amount};
use elements::hex::ToHex;
use elements::encode::serialize;
use elements::hashes::Hash;
use elements::hex::DisplayHex as _;
use elements::pset::PartiallySignedTransaction;
use elements::{AssetId, ContractHash};
use elementsd::bitcoincore_rpc::jsonrpc::serde_json::json;
Expand Down Expand Up @@ -116,7 +116,7 @@ fn tx_pegin() {
bitcoind.client.generate_to_address(101, &btc_addr).unwrap();
let proof = bitcoind.client.get_tx_out_proof(&[txid], None).unwrap();
elementsd.generate(2);
let inputs = json!([ {"txid":txid, "vout": vout,"pegin_bitcoin_tx": tx_bytes.to_hex(), "pegin_txout_proof": proof.to_hex(), "pegin_claim_script": claim_script } ]);
let inputs = json!([ {"txid":txid, "vout": vout,"pegin_bitcoin_tx": tx_bytes.to_lower_hex_string(), "pegin_txout_proof": proof.to_lower_hex_string(), "pegin_claim_script": claim_script } ]);
let outputs = json!([
{address_lbtc: "0.9", "blinder_index": 0},
{"fee": "0.1" }
Expand Down Expand Up @@ -158,7 +158,7 @@ fn psbt_rtt(elementsd: &ElementsD, base64: &str) {
b_bytes[i] = b_bytes[i].wrapping_add(1);
let base64 = BASE64_STANDARD.encode(&b_bytes);
if let Some(decoded) = elementsd.decode_psbt(&base64) {
assert_ne!(a, decoded, "{} with changed byte {}", b_bytes.to_hex(), i);
assert_ne!(a, decoded, "{} with changed byte {}", b_bytes.as_hex(), i);
}
b_bytes[i] = b_bytes[i].wrapping_sub(1);
}
Expand Down
4 changes: 2 additions & 2 deletions elementsd-tests/src/taproot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{Call, setup};

use bitcoin::key::{XOnlyPublicKey, Keypair};
use bitcoin::Amount;
use elements::hex::FromHex;
use elements::hex;
use elements::confidential::{AssetBlindingFactor, ValueBlindingFactor};
use elements::encode::{deserialize, serialize_hex};
use elements::hashes::Hash;
Expand Down Expand Up @@ -101,7 +101,7 @@ fn funded_tap_txout(
elementsd.generate(1);
let tx_hex = elementsd.get_transaction(&txid_hex);

let tx = deserialize::<Transaction>(&Vec::<u8>::from_hex(&tx_hex).unwrap()).unwrap();
let tx = deserialize::<Transaction>(&hex::decode_to_vec(&tx_hex).unwrap()).unwrap();

let mut outpoint: Option<OutPoint> = None;
for (i, out) in tx.output.iter().enumerate() {
Expand Down
12 changes: 6 additions & 6 deletions examples/pset_blind_coinjoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use elements::{pset, secp256k1_zkp};

use elements::encode::{deserialize, serialize_hex};
use elements::{confidential, AssetId, TxOut};
use elements::hex::FromHex;
use elements::hex;
use rand::SeedableRng;

// Assume txouts are simple pay to wpkh
Expand All @@ -41,7 +41,7 @@ struct Secrets {
}

fn deser_pset(psbt_hex: &str) -> Pset {
deserialize::<Pset>(&Vec::<u8>::from_hex(psbt_hex).unwrap()).unwrap()
deserialize::<Pset>(&hex::decode_to_vec(psbt_hex).unwrap()).unwrap()
}

fn parse_txout(txout_info: &str) -> (TxOut, Secrets, pset::Input) {
Expand All @@ -50,18 +50,18 @@ fn parse_txout(txout_info: &str) -> (TxOut, Secrets, pset::Input) {

let txout = TxOut {
asset: deserialize::<confidential::Asset>(
&Vec::<u8>::from_hex(v["assetcommitment"].as_str().unwrap()).unwrap(),
&hex::decode_to_vec(v["assetcommitment"].as_str().unwrap()).unwrap(),
)
.unwrap(),
value: deserialize::<confidential::Value>(
&Vec::<u8>::from_hex(v["amountcommitment"].as_str().unwrap()).unwrap(),
&hex::decode_to_vec(v["amountcommitment"].as_str().unwrap()).unwrap(),
)
.unwrap(),
nonce: deserialize::<confidential::Nonce>(
&Vec::<u8>::from_hex(v["commitmentnonce"].as_str().unwrap()).unwrap(),
&hex::decode_to_vec(v["commitmentnonce"].as_str().unwrap()).unwrap(),
)
.unwrap(),
script_pubkey: Script::from_hex(v["scriptPubKey"].as_str().unwrap()).unwrap(),
script_pubkey: Script::from_hex_no_prefix(v["scriptPubKey"].as_str().unwrap()).unwrap(),
witness: TxOutWitness::default(),
};

Expand Down
16 changes: 8 additions & 8 deletions examples/raw_blind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use elements::{pset, secp256k1_zkp, SurjectionInput};

use elements::encode::{deserialize, serialize_hex};
use elements::{confidential, AssetId, TxOut};
use elements::hex::FromHex;
use elements::hex;
use rand::SeedableRng;

/// Pset example workflow:
Expand All @@ -36,7 +36,7 @@ struct Secrets {
}

fn deser_pset(psbt_hex: &str) -> Pset {
deserialize::<Pset>(&Vec::<u8>::from_hex(psbt_hex).unwrap()).unwrap()
deserialize::<Pset>(&hex::decode_to_vec(psbt_hex).unwrap()).unwrap()
}

fn parse_txout(txout_info: &str) -> (TxOut, Secrets, pset::Input) {
Expand All @@ -45,18 +45,18 @@ fn parse_txout(txout_info: &str) -> (TxOut, Secrets, pset::Input) {

let txout = TxOut {
asset: deserialize::<confidential::Asset>(
&Vec::<u8>::from_hex(v["assetcommitment"].as_str().unwrap()).unwrap(),
&hex::decode_to_vec(v["assetcommitment"].as_str().unwrap()).unwrap(),
)
.unwrap(),
value: deserialize::<confidential::Value>(
&Vec::<u8>::from_hex(v["amountcommitment"].as_str().unwrap()).unwrap(),
&hex::decode_to_vec(v["amountcommitment"].as_str().unwrap()).unwrap(),
)
.unwrap(),
nonce: deserialize::<confidential::Nonce>(
&Vec::<u8>::from_hex(v["commitmentnonce"].as_str().unwrap()).unwrap(),
&hex::decode_to_vec(v["commitmentnonce"].as_str().unwrap()).unwrap(),
)
.unwrap(),
script_pubkey: Script::from_hex(v["scriptPubKey"].as_str().unwrap()).unwrap(),
script_pubkey: Script::from_hex_no_prefix(v["scriptPubKey"].as_str().unwrap()).unwrap(),
witness: TxOutWitness::default(),
};

Expand Down Expand Up @@ -280,13 +280,13 @@ fn main() {
tx.verify_tx_amt_proofs(&secp, &[btc_txout, asset_txout])
.unwrap();

let inp0_sig = Vec::<u8>::from_hex("3044022040d1802d6e10da4c27f05eff807550e614b3d2fa20c663dbf1ebf162d3952689022001f477c953b7c543bce877e3297fccb00ef5dba21d427e79c8bfb8522713309801").unwrap();
let inp0_sig = hex::hex!("3044022040d1802d6e10da4c27f05eff807550e614b3d2fa20c663dbf1ebf162d3952689022001f477c953b7c543bce877e3297fccb00ef5dba21d427e79c8bfb8522713309801").to_vec();
let inp0_pk = PublicKey::from_str(
"0334c307ad8142e7c8a6bf1ad3552b12fbb860885ea7f2d76c1f49f93a7c4bbbe7",
)
.unwrap();

let inp1_sig = Vec::<u8>::from_hex("3044022017c696503f5e1539fe5cb8dd05f793bd3b6e39f193028a7299a80c94c817a02d022007889009088f46cd9d9f4d137815704170410f53d503b68c1e020292a85b93fa01").unwrap();
let inp1_sig = hex::hex!("3044022017c696503f5e1539fe5cb8dd05f793bd3b6e39f193028a7299a80c94c817a02d022007889009088f46cd9d9f4d137815704170410f53d503b68c1e020292a85b93fa01").to_vec();
let inp1_pk = PublicKey::from_str(
"03df8f51c053ba0dfb443cce9793b6dc3339ffb0ce97af4792dade3aae1eb890f6",
)
Expand Down
4 changes: 2 additions & 2 deletions examples/tx.rs

Large diffs are not rendered by default.

70 changes: 21 additions & 49 deletions src/blind.rs

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ impl Block {
#[cfg(test)]
mod tests {
use crate::Block;
use crate::hex::FromHex;

use super::*;

Expand Down Expand Up @@ -796,7 +795,7 @@ mod tests {
fn test_failed_block() {
let block_str = include_str!("../tests/data/failedblock.hex");

let bytes = Vec::<u8>::from_hex(block_str).unwrap();
let bytes = hex::decode_to_vec(block_str).unwrap();
let _block = encode::deserialize::<Block>(&bytes).unwrap();
}
}
Loading
Loading