commit 40dbf1fc0daeb979fd78cdb5819b367bfd17a8d5
parent 074bb420b83fdb6f14e15253bc23cd0360416b8c
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Tue, 19 Apr 2022 12:27:11 +0200
add test decoding logic
Diffstat:
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/btc-wire/src/bin/segwit-demo.rs b/btc-wire/src/bin/segwit-demo.rs
@@ -1,14 +1,15 @@
use bitcoin::Amount;
use btc_wire::{rpc_utils, segwit::encode_segwit_addr};
+use btc_wire::{segwit::decode_segwit_msg};
use common::{
base32::{self, Alphabet},
rand_slice,
};
pub fn main() {
- let address = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4";
- let amount = Amount::from_sat(10000000);
- let reserve_pub = "0ZSX8SH0M30KHX8K3Y1DAMVGDQV82XEF9DG1HC4QMQ3QWYT4AF00";
+ let address = "tb1qhxrhccqexg0dv4nltgkuw4fg2ce7muplmjsn0v";
+ let amount = Amount::from_sat(5000000);
+ let reserve_pub = "54ZN9AMVN1R0YZ68ZPVHHQA4KZE1V037M05FNMYH4JQ596YAKJEG";
let btc = amount.as_btc();
println!("Ⅰ - Parse payto uri");
@@ -69,5 +70,14 @@ pub fn main() {
}
println!(
"Make sure the amount show 0.10000588 BTC, else you have to change the base unit to BTC"
- )
+ );
+
+
+ let key1 = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4";
+ let key2 = "tb1qzxwu2p7urkqx0gq2ltfazf9w2jdu48ya8qwlm0";
+ let key3 = "tb1qzxwu2pef8a224xagwq8hej8akuvd63yluu3wrh";
+ let addresses = vec![key1, key2, key3];
+ let dec = decode_segwit_msg(&addresses);
+
+ println!("Decode reserve public key: 0x{}", hex::encode(&dec.unwrap()[..]));
}