Skip to content

Commit 01a68b7

Browse files
committed
feat: add optional fields
1 parent beb74a9 commit 01a68b7

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iop-python"
3-
version = "0.1.3"
3+
version = "0.1.5"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ receiver = "taQb8gfnetDt6KtRH3n11M3APMzrWiBhhg"
8888
amount = "100"
8989
nonce = 1
9090
key = 0
91-
network = "devnet"
92-
tx_data = iop.generate_transaction(vault,receiver,amount,nonce,password,key,network)
91+
network = "testnet"
92+
fee = 10000
93+
comment = "sending money"
94+
tx_data = iop.generate_transaction(vault,receiver,amount,nonce,password,key,network,comment,fee)
9395
```
9496

9597
- `verify_signed_statement`: Verifies the signature of a signed witness statement and returns a boolean indicating whether the signature is valid.

src/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl FromStr for Network {
9494
#[allow(unused_variables)]
9595
pub fn get_hyd_vault(phrase: String, password: String, network: String) -> PyResult<String> {
9696
let mut vault =
97-
Vault::create(None, phrase, &password, &password).expect("Vault could not be initialised");
97+
Vault::create(None, phrase, "", &password).expect("Vault could not be initialised");
9898
let network = network.parse::<Network>().unwrap().network;
9999
let params = hydra::Parameters::new(&*network, 0);
100100
hydra::Plugin::init(&mut vault, &password, &params).expect("plugin could not be initialised");
@@ -108,7 +108,7 @@ pub fn get_hyd_vault(phrase: String, password: String, network: String) -> PyRes
108108
#[allow(unused_variables)]
109109
pub fn get_morpheus_vault(phrase: String, password: String) -> Result<String, PyErr> {
110110
//let mut vault = Vault::create(None, phrase, &password, &password).expect("Vault could not be initialised");
111-
let vault = Vault::create(None, phrase, &password, &password);
111+
let vault = Vault::create(None, phrase, "", &password);
112112
match vault {
113113
Ok(mut vault) => {
114114
morpheus::Plugin::init(&mut vault, &password).unwrap();
@@ -255,7 +255,8 @@ pub fn generate_transaction<'a>(
255255
password: String,
256256
account: i32,
257257
network: &'a str,
258-
vendor_field: Option<String>
258+
vendor_field: Option<String>,
259+
manual_fee: Option<u64>,
259260
) -> PyResult<String> {
260261
let mut transactions = Vec::new();
261262
let signer = deserialize_hydra(data, password, account,network).unwrap();
@@ -264,7 +265,7 @@ pub fn generate_transaction<'a>(
264265
let nonce = nonce + 1;
265266
let optional = OptionalTransactionFields {
266267
amount,
267-
manual_fee: None,
268+
manual_fee,
268269
vendor_field,
269270
};
270271
let common_fields = CommonTransactionFields {

test.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313

1414

1515

16-
1716
password="horse-staple-God"
18-
data = iop.get_hyd_vault(mainnet_phrase,password,"mainnet")
17+
data = iop.get_hyd_vault(phrase,password,"mainnet")
1918
wallet = iop.get_wallet(data,0,"mainnet")
2019
print(wallet) # hVKiVHyKFzsm2MdKR2NxBCs3K8EoKGz3Dq
21-
response = iop.generate_transaction(data,"hbnPgtVbYkDQkcWA47nbdZNfbstYQUay9D",50000000,8,password,0,"mainnet") # send 0.5
22-
url = "http://explorer.hydraledger.tech:4703/api/v2/transactions"
23-
res = requests.post(url, json=json.loads(response))
24-
response = res.json()
20+
comment = 'sending money'
21+
fee = 1000000
22+
response = iop.generate_transaction(data,"hbnPgtVbYkDQkcWA47nbdZNfbstYQUay9D",50000000,8,password,0,"mainnet",comment,fee) # send 0.5
2523
print(response)
24+
url = "http://explorer.hydraledger.tech:4703/api/v2/transactions"
25+
# res = requests.post(url, json=json.loads(response))
26+
# response = res.json()
27+
# print(response)

0 commit comments

Comments
 (0)