Skip to content

Commit eafdfc7

Browse files
author
Antoine Riard
committed
Add serialization/deserialization BitcoinOutpoint
1 parent 5764634 commit eafdfc7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/util/ser.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use secp256k1::Signature;
1010
use secp256k1::key::{PublicKey, SecretKey};
1111
use bitcoin::util::hash::Sha256dHash;
1212
use bitcoin::blockdata::script::Script;
13+
use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
1314
use std::marker::Sized;
1415
use ln::msgs::DecodeError;
1516
use ln::channelmanager::{PaymentPreimage, PaymentHash};
@@ -420,3 +421,20 @@ impl<R, T> Readable<R> for Option<T>
420421
}
421422
}
422423
}
424+
425+
426+
impl<R: Read> Readable<R> for BitcoinOutPoint {
427+
fn read(r: &mut R) -> Result<Self, DecodeError> {
428+
let txid = Readable::read(r)?;
429+
let vout = Readable::read(r)?;
430+
Ok(BitcoinOutPoint { txid, vout })
431+
}
432+
}
433+
434+
impl Writeable for BitcoinOutPoint {
435+
fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
436+
self.txid.as_bytes().write(w)?;
437+
w.write_all(&byte_utils::be32_to_array(self.vout))?;
438+
Ok(())
439+
}
440+
}

0 commit comments

Comments
 (0)