mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-02-12 02:05:47 +00:00
Fetch consensusBranchId from server
This commit is contained in:
parent
3479dc345a
commit
c1432a3810
@ -50,6 +50,7 @@ message LightdInfo {
|
||||
bool taddrSupport = 3;
|
||||
string chainName = 4;
|
||||
uint64 saplingActivationHeight = 5;
|
||||
string consensusBranchId = 6; // This should really be u32 or []byte, but string for readability
|
||||
}
|
||||
|
||||
message TransparentAddress {
|
||||
@ -61,15 +62,6 @@ message TransparentAddressBlockFilter {
|
||||
BlockRange range = 2;
|
||||
}
|
||||
|
||||
message Utxo {
|
||||
TransparentAddress address = 1;
|
||||
bytes txid = 2;
|
||||
uint64 outputIndex = 3;
|
||||
bytes script = 4;
|
||||
uint64 value = 5;
|
||||
uint64 height = 6;
|
||||
}
|
||||
|
||||
service CompactTxStreamer {
|
||||
// Compact Blocks
|
||||
rpc GetLatestBlock(ChainSpec) returns (BlockID) {}
|
||||
@ -81,7 +73,6 @@ service CompactTxStreamer {
|
||||
rpc SendTransaction(RawTransaction) returns (SendResponse) {}
|
||||
|
||||
// t-Address support
|
||||
rpc GetUtxos(TransparentAddress) returns (stream Utxo) {}
|
||||
rpc GetAddressTxids(TransparentAddressBlockFilter) returns (stream RawTransaction) {}
|
||||
|
||||
// Misc
|
||||
|
@ -41,6 +41,7 @@ pub struct LightClientConfig {
|
||||
pub server : String,
|
||||
pub chain_name : String,
|
||||
pub sapling_activation_height : u64,
|
||||
pub consensus_branch_id : String,
|
||||
}
|
||||
|
||||
impl LightClientConfig {
|
||||
@ -724,7 +725,7 @@ impl LightClient {
|
||||
pub fn do_send(&self, addr: &str, value: u64, memo: Option<String>) -> String {
|
||||
info!("Creating transaction");
|
||||
let rawtx = self.wallet.send_to_address(
|
||||
u32::from_str_radix("2bb40e60", 16).unwrap(), // Blossom ID
|
||||
u32::from_str_radix(&self.config.consensus_branch_id, 16).unwrap(), // Blossom ID
|
||||
&self.sapling_spend, &self.sapling_output,
|
||||
&addr, value, memo
|
||||
);
|
||||
|
@ -1461,11 +1461,7 @@ pub mod tests {
|
||||
|
||||
#[test]
|
||||
fn z_balances() {
|
||||
let wallet = LightWallet::new(None, &LightClientConfig {
|
||||
server: "0.0.0.0:0".to_string(),
|
||||
chain_name: "test".to_string(),
|
||||
sapling_activation_height: 0
|
||||
}).unwrap();
|
||||
let wallet = LightWallet::new(None, &get_test_config()).unwrap();
|
||||
|
||||
const AMOUNT1:u64 = 5;
|
||||
// Address is encoded in bech32
|
||||
@ -1504,11 +1500,7 @@ pub mod tests {
|
||||
|
||||
#[test]
|
||||
fn z_change_balances() {
|
||||
let wallet = LightWallet::new(None, &LightClientConfig {
|
||||
server: "0.0.0.0:0".to_string(),
|
||||
chain_name: "test".to_string(),
|
||||
sapling_activation_height: 0
|
||||
}).unwrap();
|
||||
let wallet = LightWallet::new(None, &get_test_config()).unwrap();
|
||||
|
||||
// First, add an incoming transaction
|
||||
const AMOUNT1:u64 = 5;
|
||||
@ -1557,11 +1549,7 @@ pub mod tests {
|
||||
let mut rng = OsRng;
|
||||
let secp = Secp256k1::new();
|
||||
|
||||
let wallet = LightWallet::new(None, &LightClientConfig {
|
||||
server: "0.0.0.0:0".to_string(),
|
||||
chain_name: "test".to_string(),
|
||||
sapling_activation_height: 0
|
||||
}).unwrap();
|
||||
let wallet = LightWallet::new(None, &get_test_config()).unwrap();
|
||||
|
||||
let pk = PublicKey::from_secret_key(&secp, &wallet.tkeys[0]);
|
||||
let taddr = wallet.address_from_sk(&wallet.tkeys[0]);
|
||||
@ -1627,11 +1615,7 @@ pub mod tests {
|
||||
let mut rng = OsRng;
|
||||
let secp = Secp256k1::new();
|
||||
|
||||
let wallet = LightWallet::new(None, &LightClientConfig {
|
||||
server: "0.0.0.0:0".to_string(),
|
||||
chain_name: "test".to_string(),
|
||||
sapling_activation_height: 0
|
||||
}).unwrap();
|
||||
let wallet = LightWallet::new(None, &get_test_config()).unwrap();
|
||||
|
||||
let pk = PublicKey::from_secret_key(&secp, &wallet.tkeys[0]);
|
||||
let taddr = wallet.address_from_sk(&wallet.tkeys[0]);
|
||||
@ -1698,11 +1682,7 @@ pub mod tests {
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
let secp = Secp256k1::new();
|
||||
let config = LightClientConfig {
|
||||
server: "0.0.0.0:0".to_string(),
|
||||
chain_name: "test".to_string(),
|
||||
sapling_activation_height: 0
|
||||
};
|
||||
let config = get_test_config();
|
||||
|
||||
let wallet = LightWallet::new(None, &config).unwrap();
|
||||
|
||||
@ -1808,13 +1788,18 @@ pub mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
// Get a test wallet already setup with a single note
|
||||
fn get_test_wallet(amount: u64) -> (LightWallet, LightClientConfig, TxId, BlockHash) {
|
||||
let config = LightClientConfig {
|
||||
fn get_test_config() -> LightClientConfig {
|
||||
LightClientConfig {
|
||||
server: "0.0.0.0:0".to_string(),
|
||||
chain_name: "test".to_string(),
|
||||
sapling_activation_height: 0
|
||||
};
|
||||
sapling_activation_height: 0,
|
||||
consensus_branch_id: "000000".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get a test wallet already setup with a single note
|
||||
fn get_test_wallet(amount: u64) -> (LightWallet, LightClientConfig, TxId, BlockHash) {
|
||||
let config = get_test_config();
|
||||
|
||||
let wallet = LightWallet::new(None, &config).unwrap();
|
||||
|
||||
|
@ -55,6 +55,7 @@ pub fn main() {
|
||||
server,
|
||||
chain_name : info.chain_name,
|
||||
sapling_activation_height : info.sapling_activation_height,
|
||||
consensus_branch_id : info.consensus_branch_id,
|
||||
};
|
||||
|
||||
let lightclient = match LightClient::new(seed, &config) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user