Ok the bdk looks like a far better bet!

This commit is contained in:
Dave Hrycyszyn
2024-06-21 17:00:01 +01:00
parent 933fea76df
commit ac6473bb1b
5 changed files with 952 additions and 42 deletions

View File

@@ -1,8 +1,6 @@
use std::path::PathBuf;
use bft_json_crdt::json_crdt::SignedOp;
use bitcoin::{absolute, key::Keypair, transaction::Version, TxIn, TxOut};
use serde_json::{json, Value};
use std::path::PathBuf;
pub(crate) const BITCOIN_KEY_FILE: &str = "bitcoin_keys.pem";
pub(crate) const BFT_CRDT_KEY_FILE: &str = "keys.pem";
@@ -40,29 +38,29 @@ pub fn fake_generic_transaction_json(from: String) -> Value {
}
/// Generate a Bitcoin transaction from this node's bitcoin_keys
pub fn fake_bitcoin_transaction(key_pair: Keypair) -> bitcoin::Transaction {
let from = key_pair.public_key().to_string();
let to = "Bob";
let amount = 1;
let lock_time = absolute::LockTime::from_height(0).expect("couldn't format btc lock time");
let input = TxIn {
previous_output: todo!(),
script_sig: todo!(),
sequence: todo!(),
witness: todo!(),
};
let output = TxOut {
value: todo!(),
script_pubkey: todo!(),
};
let tx = bitcoin::Transaction {
version: Version(1),
lock_time,
input: vec![input],
output: vec![output],
};
tx
}
// pub fn fake_bitcoin_transaction(key_pair: Keypair) -> bitcoin::Transaction {
// let from = key_pair.public_key().to_string();
// let to = "Bob";
// let amount = 1;
// let lock_time = absolute::LockTime::from_height(0).expect("couldn't format btc lock time");
// let input = TxIn {
// previous_output: todo!(),
// script_sig: todo!(),
// sequence: todo!(),
// witness: todo!(),
// };
// let output = TxOut {
// value: todo!(),
// script_pubkey: todo!(),
// };
// let tx = bitcoin::Transaction {
// version: Version(1),
// lock_time,
// input: vec![input],
// output: vec![output],
// };
// tx
// }
pub fn shappy(op: SignedOp) -> String {
let b = serde_json::to_string(&op).unwrap().into_bytes();