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