@@ -277,6 +277,7 @@ pub async fn process_tx(
277277 // We use this to determine when the wrapper tx makes it on-chain
278278 let tx_hash = tx. header_hash ( ) . to_string ( ) ;
279279 let cmts = tx. commitments ( ) . clone ( ) ;
280+ // FIXME: add a check to avoid submitting raw txs? Yes
280281 let wrapper_hash = tx. wrapper_hash ( ) ;
281282 // We use this to determine when the inner tx makes it
282283 // on-chain
@@ -5009,7 +5010,7 @@ pub async fn build_custom(
50095010 signatures,
50105011 wrapper_signature,
50115012 } : & args:: TxCustom ,
5012- ) -> Result < ( Tx , Option < SigningData > ) > {
5013+ ) -> Result < ( Tx , SigningData ) > {
50135014 let mut tx = if let Some ( serialized_tx) = serialized_tx {
50145015 Tx :: try_from_json_bytes ( serialized_tx. as_ref ( ) ) . map_err ( |_| {
50155016 Error :: Other (
@@ -5048,49 +5049,44 @@ pub async fn build_custom(
50485049 // 2. If only the inner sigs were provided we generate a SigningData that
50495050 // will attach them and then sign the wrapper online
50505051 // 3. If the wrapper signature was provided then we also expect the inner
5051- // signature(s) to have been provided, in this case we attach all the
5052- // signatures here and return no SigningData
5053- let signing_data = if let Some ( wrapper_signature) = & wrapper_signature {
5052+ // signature(s) to have been provided, in this case we generate a
5053+ // SigningData to attach all these signatures
5054+ let signing_data = if wrapper_signature. is_some ( ) {
50545055 if tx. header . wrapper ( ) . is_none ( ) {
50555056 return Err ( Error :: Other (
50565057 "A wrapper signature was provided but the transaction is not \
50575058 a wrapper"
50585059 . to_string ( ) ,
50595060 ) ) ;
50605061 }
5061- // Attach the provided signatures to the tx without the need to produce
5062- // any more signatures
5063- // FIXME: don't we attach the signatures when we dump the tx?
5064- let signatures = signatures. iter ( ) . try_fold (
5065- vec ! [ ] ,
5066- |mut acc, bytes| -> Result < Vec < _ > > {
5067- let sig = SignatureIndex :: try_from_json_bytes ( bytes) . map_err (
5068- |err| Error :: Encode ( EncodingError :: Serde ( err. to_string ( ) ) ) ,
5069- ) ?;
5070- acc. push ( sig) ;
5071- Ok ( acc)
5072- } ,
5073- ) ?;
5074- tx. add_signatures ( signatures)
5075- . add_section ( Section :: Authorization (
5076- serde_json:: from_slice ( wrapper_signature) . map_err ( |err| {
5077- Error :: Encode ( EncodingError :: Serde ( err. to_string ( ) ) )
5078- } ) ?,
5079- ) ) ;
5080- None
5062+
5063+ SigningData :: Wrapper (
5064+ signing:: aux_signing_data (
5065+ context,
5066+ tx_args,
5067+ owner. clone ( ) ,
5068+ owner. clone ( ) ,
5069+ vec ! [ ] ,
5070+ // The wrapper signature is provided so no need to generate a
5071+ // disposable address anyway
5072+ false ,
5073+ signatures. to_owned ( ) ,
5074+ wrapper_signature. to_owned ( ) ,
5075+ )
5076+ . await ?,
5077+ )
50815078 } else {
50825079 let signing_data = signing:: aux_signing_data (
50835080 context,
50845081 tx_args,
50855082 owner. clone ( ) ,
50865083 owner. clone ( ) ,
50875084 vec ! [ ] ,
5088- // FIXME: is this correct? Probably not I should chech the owner
5085+ // The possible masp fee paying transaction has already been
5086+ // produced so no need to generate a disposable address anyway
50895087 false ,
50905088 signatures. to_owned ( ) ,
5091- // FIXME: actually can't we unify the two branches and pass the
5092- // wrapper signatures here?
5093- None ,
5089+ wrapper_signature. to_owned ( ) ,
50945090 )
50955091 . await ?;
50965092
@@ -5106,10 +5102,20 @@ pub async fn build_custom(
51065102 fee_payer,
51075103 wrap_tx. gas_limit ,
51085104 ) ;
5105+ SigningData :: Wrapper ( signing_data)
5106+ } else {
5107+ SigningData :: Inner (
5108+ signing:: aux_inner_signing_data (
5109+ context,
5110+ tx_args,
5111+ owner. clone ( ) ,
5112+ owner. clone ( ) ,
5113+ vec ! [ ] ,
5114+ signatures. to_owned ( ) ,
5115+ )
5116+ . await ?,
5117+ )
51095118 }
5110- // FIXME: what if we want to load a raw tx, sign the inner and nothing
5111- // else? No wrapping
5112- Some ( SigningData :: Wrapper ( signing_data) )
51135119 } ;
51145120
51155121 Ok ( ( tx, signing_data) )
0 commit comments