Unable to decode serialized TxOut
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- rust
- Domain
- blockchain
Research direction
Start in src/transaction.rs at the TxOut and TxOutWitness definitions and the serialization behavior around the cited lines, then reproduce the issue with the provided transaction and round-trip snippet. Done means a serialized and deserialized TxOut retains its rangeproof so unblind succeeds; add or update regression coverage if the repository provides a suitable location.
Written by the indexing model from the issue text.
Description
There is an issue in serialization of TxOut, we're unable to decode it after serialization.
The problem lyes in the simplicityhl::elements::encode::serialize.
For unblinding it misses Rangeproof inside. For some reason it isn't serialized inside.
TxOut contains TxOutSecrets inside https://github.com/ElementsProject/rust-elements/blob/2d94f5dcb5e4a81838681c71ed8a49b337feecd2/src/transaction.rs#L703, but TxOutWitness has its own serialization https://github.com/ElementsProject/rust-elements/blob/2d94f5dcb5e4a81838681c71ed8a49b337feecd2/src/transaction.rs#L653 while TxOut just truncates it https://github.com/ElementsProject/rust-elements/blob/2d94f5dcb5e4a81838681c71ed8a49b337feecd2/src/transaction.rs#L719.
Here is a quick code snippet to test it:
use std::time::Duration;
use simplicityhl::elements::{ Transaction, TxOut,};
use simplicityhl::elements::bitcoin::secp256k1;
use simplicityhl::elements::encode;
pub const PUBLIC_SECRET_BLINDER_KEY: [u8; 32] = [1; 32];
let secret_key = SecretKey::from_slice(&PUBLIC_SECRET_BLINDER_KEY).unwrap();
let tx_id = "8e12b0c994293d15b7f43abaeb6c119ce3612ff00246b7ae9079dca90a35031f";
let url = format!("https://blockstream.info/liquidtestnet/api/tx/{}/hex", tx_id);
let client = reqwest::blocking::Client::builder()
.timeout(Duration::from_secs(10))
.build()
.unwrap();
let tx_hex = client
.get(&url)
.send()
.unwrap()
.error_for_status()
.unwrap()
.text()
.unwrap();
let transaction: Transaction = encode::deserialize(&hex::decode(&tx_hex).unwrap()).unwrap();
let tx_out_from_reqwest = transaction.output[0].clone();
assert!(tx_out_from_reqwest.unblind(secp256k1::SECP256K1, secret_key).is_ok());
let tx_out_from_request_serialized = encode::serialize(&tx_out_from_reqwest);
let tx_out_from_request_deserialized: TxOut = encode::deserialize(&tx_out_from_request_serialized).unwrap();
assert!(tx_out_from_request_deserialized.unblind(secp256k1::SECP256K1, secret_key).is_ok());
- Dominant language
- Rust
- Stars
- 57
- Forks
- 40
- Avg merge
- 11h 58m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ElementsProject/rust-elements
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
ElementsProject/rust-elements#290 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ElementsProject/rust-elements#277 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
ElementsProject/rust-elements#273 · 3 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
ElementsProject/rust-elements#268 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
ElementsProject/rust-elements#260 · 1 comment ·
All issues in ElementsProject/rust-elements
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100