Merge pull request 'Fix Sapling spend parsing' (#69) from rav001 into dev040

Reviewed-on: #69
This commit is contained in:
pitmutt 2024-04-24 17:02:40 +00:00 committed by Vergara Technologies LLC
commit 586cb4646c
Signed by: Vergara Technologies LLC
GPG key ID: 99DB473BB4715618
3 changed files with 34 additions and 9 deletions

View file

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Orchard note nullifier calculation - Orchard note nullifier calculation
- Sapling spend field parsing
## [0.5.5.2] ## [0.5.5.2]

View file

@ -401,9 +401,9 @@ impl<RW> ToHaskell<RW> for HSBundle {
impl HSBundle { impl HSBundle {
pub fn from_bundle(sb: &SaplingBundle<SaplingAuthorized>) -> HSBundle { pub fn from_bundle(sb: &SaplingBundle<SaplingAuthorized>) -> HSBundle {
let s = Cursor::new(Vec::new()); let mut s: Vec<u8> = Vec::new();
sb.authorization().binding_sig.write(s.clone()).unwrap(); sb.authorization().binding_sig.write(&mut s).unwrap();
return HSBundle {empty: false, spends: Hspend::pack(sb.shielded_spends()) , outputs: HshieldedOutput::pack(sb.shielded_outputs()) , value: i64::from(sb.value_balance()) , sig: s.into_inner() } return HSBundle {empty: false, spends: Hspend::pack(sb.shielded_spends()) , outputs: HshieldedOutput::pack(sb.shielded_outputs()) , value: i64::from(sb.value_balance()) , sig: s }
} }
} }
@ -428,11 +428,11 @@ impl Hspend {
pub fn pack(sp: &[SpendDescription<SaplingAuthorized>]) -> Vec<Hspend> { pub fn pack(sp: &[SpendDescription<SaplingAuthorized>]) -> Vec<Hspend> {
let mut r = Vec::new(); let mut r = Vec::new();
for s in sp { for s in sp {
let rk = Cursor::new(Vec::new()); let mut rk = Vec::new();
let authsig = Cursor::new(Vec::new()); let mut authsig = Vec::new();
s.rk().write(rk.clone()).unwrap(); s.rk().write(&mut rk).unwrap();
s.spend_auth_sig().write(authsig.clone()).unwrap(); s.spend_auth_sig().write(&mut authsig).unwrap();
r.push(Hspend {cv: Hhex{bytes:s.cv().to_bytes().to_vec()}, anchor: Hhex{bytes:s.anchor().to_bytes().to_vec()}, nullifier: Hhex{bytes:s.nullifier().to_vec()}, rk: Hhex{bytes: rk.into_inner()}, proof: Hhex{bytes:s.zkproof().to_vec()}, authsig: Hhex{bytes:authsig.into_inner()}}); r.push(Hspend {cv: Hhex{bytes:s.cv().to_bytes().to_vec()}, anchor: Hhex{bytes:s.anchor().to_bytes().to_vec()}, nullifier: Hhex{bytes:s.nullifier().to_vec()}, rk: Hhex{bytes: rk}, proof: Hhex{bytes:s.zkproof().to_vec()}, authsig: Hhex{bytes:authsig}});
} }
return r return r
} }

File diff suppressed because one or more lines are too long