mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-07-30 03:41:28 +00:00
Convert P2SH address to script_pubkey
This commit is contained in:
@@ -48,33 +48,33 @@ reqwest = { version = "0.10.8", features = ["blocking", "json"] }
|
|||||||
|
|
||||||
[dependencies.bellman]
|
[dependencies.bellman]
|
||||||
git = "https://github.com/CalDescent1/librustzcash.git"
|
git = "https://github.com/CalDescent1/librustzcash.git"
|
||||||
rev = "5a4fd01f351259694c31ca161842dfd7078ef2f1"
|
rev = "1a8686863b10a608ececdede3deb82d2fb4218fa"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["groth16", "multicore"]
|
features = ["groth16", "multicore"]
|
||||||
|
|
||||||
[dependencies.pairing]
|
[dependencies.pairing]
|
||||||
git = "https://github.com/CalDescent1/librustzcash.git"
|
git = "https://github.com/CalDescent1/librustzcash.git"
|
||||||
rev = "5a4fd01f351259694c31ca161842dfd7078ef2f1"
|
rev = "1a8686863b10a608ececdede3deb82d2fb4218fa"
|
||||||
|
|
||||||
[dependencies.zcash_client_backend]
|
[dependencies.zcash_client_backend]
|
||||||
git = "https://github.com/CalDescent1/librustzcash.git"
|
git = "https://github.com/CalDescent1/librustzcash.git"
|
||||||
rev = "5a4fd01f351259694c31ca161842dfd7078ef2f1"
|
rev = "1a8686863b10a608ececdede3deb82d2fb4218fa"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.zcash_primitives]
|
[dependencies.zcash_primitives]
|
||||||
git = "https://github.com/CalDescent1/librustzcash.git"
|
git = "https://github.com/CalDescent1/librustzcash.git"
|
||||||
rev = "5a4fd01f351259694c31ca161842dfd7078ef2f1"
|
rev = "1a8686863b10a608ececdede3deb82d2fb4218fa"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["transparent-inputs"]
|
features = ["transparent-inputs"]
|
||||||
|
|
||||||
[dependencies.zcash_proofs]
|
[dependencies.zcash_proofs]
|
||||||
git = "https://github.com/CalDescent1/librustzcash.git"
|
git = "https://github.com/CalDescent1/librustzcash.git"
|
||||||
rev = "5a4fd01f351259694c31ca161842dfd7078ef2f1"
|
rev = "1a8686863b10a608ececdede3deb82d2fb4218fa"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.ff]
|
[dependencies.ff]
|
||||||
git = "https://github.com/CalDescent1/librustzcash.git"
|
git = "https://github.com/CalDescent1/librustzcash.git"
|
||||||
rev = "5a4fd01f351259694c31ca161842dfd7078ef2f1"
|
rev = "1a8686863b10a608ececdede3deb82d2fb4218fa"
|
||||||
features = ["ff_derive"]
|
features = ["ff_derive"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@@ -77,7 +77,7 @@ pub fn double_sha256(payload: &[u8]) -> Vec<u8> {
|
|||||||
h2.to_vec()
|
h2.to_vec()
|
||||||
}
|
}
|
||||||
|
|
||||||
use base58::{ToBase58};
|
use base58::{FromBase58, ToBase58};
|
||||||
|
|
||||||
/// A trait for converting a [u8] to base58 encoded string.
|
/// A trait for converting a [u8] to base58 encoded string.
|
||||||
pub trait ToBase58Check {
|
pub trait ToBase58Check {
|
||||||
@@ -2887,14 +2887,18 @@ impl LightWallet {
|
|||||||
|
|
||||||
// Add P2SH transaction as transparent input, including secret and redeem script
|
// Add P2SH transaction as transparent input, including secret and redeem script
|
||||||
|
|
||||||
|
let p2sh_addr_vec = from.from_base58().unwrap();
|
||||||
|
let p2sh_addr_arr = <[u8; 20]>::try_from(&p2sh_addr_vec[2..22]).unwrap();
|
||||||
|
let p2sh_script_pubkey = TransparentAddress::PublicKey(p2sh_addr_arr).script();
|
||||||
|
|
||||||
let outpoint: OutPoint = OutPoint {
|
let outpoint: OutPoint = OutPoint {
|
||||||
hash: <[u8; 32]>::try_from(outpoint_txid).unwrap(),
|
hash: <[u8; 32]>::try_from(outpoint_txid).unwrap(),
|
||||||
n: 0
|
n: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
let coin = TxOut {
|
let coin = TxOut {
|
||||||
value: Amount::from_u64(total_value).unwrap(),
|
value: target_value,
|
||||||
script_pubkey: Script { 0: redeem_script_pubkey.to_vec() },
|
script_pubkey: p2sh_script_pubkey,
|
||||||
};
|
};
|
||||||
|
|
||||||
let sk = SecretKey::from_slice(privkey).unwrap();
|
let sk = SecretKey::from_slice(privkey).unwrap();
|
||||||
|
Reference in New Issue
Block a user