@@ -18,9 +18,46 @@ use crate::merkle::cmr::Cmr;
1818
1919use super :: ElementsUtxo ;
2020
21+ /// Holds transaction output data which needs to be re-serialized before being
22+ /// passed to the C FFI.
23+ #[ derive( Debug ) ]
24+ struct RawOutputData {
25+ pub asset : Option < [ c_uchar ; 33 ] > ,
26+ pub value : Vec < c_uchar > ,
27+ pub nonce : Option < [ c_uchar ; 33 ] > ,
28+ pub surjection_proof : Vec < c_uchar > ,
29+ pub range_proof : Vec < c_uchar > ,
30+ }
31+
32+ /// Holds transaction input data which needs to be re-serialized before being
33+ /// passed to the C FFI.
34+ #[ derive( Debug ) ]
35+ struct RawInputData {
36+ #[ allow( dead_code) ] // see FIXME below
37+ pub annex : Option < Vec < c_uchar > > ,
38+ // pegin
39+ pub genesis_hash : Option < [ c_uchar ; 32 ] > ,
40+ // issuance
41+ pub issuance_amount : Vec < c_uchar > ,
42+ pub issuance_inflation_keys : Vec < c_uchar > ,
43+ pub amount_range_proof : Vec < c_uchar > ,
44+ pub inflation_keys_range_proof : Vec < c_uchar > ,
45+ // spent txo
46+ pub asset : Option < [ c_uchar ; 33 ] > ,
47+ pub value : Vec < c_uchar > ,
48+ }
49+
50+ /// Holds transaction data which needs to be re-serialized before being
51+ /// passed to the C FFI.
52+ #[ derive( Debug ) ]
53+ struct RawTransactionData {
54+ pub inputs : Vec < RawInputData > ,
55+ pub outputs : Vec < RawOutputData > ,
56+ }
57+
2158fn new_raw_output < ' raw > (
2259 out : & elements:: TxOut ,
23- out_data : & ' raw c_elements :: RawOutputData ,
60+ out_data : & ' raw RawOutputData ,
2461) -> c_elements:: CRawOutput < ' raw > {
2562 c_elements:: CRawOutput {
2663 asset : out_data. asset . as_ref ( ) ,
@@ -35,7 +72,7 @@ fn new_raw_output<'raw>(
3572fn new_raw_input < ' raw > (
3673 inp : & ' raw elements:: TxIn ,
3774 in_utxo : & ' raw ElementsUtxo ,
38- inp_data : & ' raw c_elements :: RawInputData ,
75+ inp_data : & ' raw RawInputData ,
3976) -> c_elements:: CRawInput < ' raw > {
4077 c_elements:: CRawInput {
4178 // FIXME actually pass the annex in; see https://github.com/BlockstreamResearch/simplicity/issues/311 for some difficulty here.
@@ -70,16 +107,13 @@ fn new_raw_input<'raw>(
70107 }
71108}
72109
73- fn new_tx_data (
74- tx : & elements:: Transaction ,
75- in_utxos : & [ ElementsUtxo ] ,
76- ) -> c_elements:: RawTransactionData {
77- let mut tx_data = c_elements:: RawTransactionData {
110+ fn new_tx_data ( tx : & elements:: Transaction , in_utxos : & [ ElementsUtxo ] ) -> RawTransactionData {
111+ let mut tx_data = RawTransactionData {
78112 inputs : Vec :: with_capacity ( tx. input . len ( ) ) ,
79113 outputs : Vec :: with_capacity ( tx. output . len ( ) ) ,
80114 } ;
81115 for ( inp, in_utxo) in tx. input . iter ( ) . zip ( in_utxos. iter ( ) ) {
82- let inp_data = c_elements :: RawInputData {
116+ let inp_data = RawInputData {
83117 annex : None , // Actually store annex
84118 genesis_hash : inp
85119 . pegin_data ( )
@@ -96,7 +130,7 @@ fn new_tx_data(
96130 tx_data. inputs . push ( inp_data) ;
97131 }
98132 for out in & tx. output {
99- let out_data = c_elements :: RawOutputData {
133+ let out_data = RawOutputData {
100134 asset : asset_array ( & out. asset ) ,
101135 value : serialize ( & out. value ) ,
102136 nonce : nonce_array ( & out. nonce ) ,
0 commit comments