p2pderivatives / rust-dlc

Rust library for working with Discreet Log Contracts
MIT License
138 stars 36 forks source link

No addresses with label xxxxx #209

Closed h10086733 closed 5 months ago

h10086733 commented 6 months ago

cargo run ./examples/configurations/alice.yml Finished dev [unoptimized + debuginfo] target(s) in 0.05s Running /home/qiyun/project/rust-dlc/target/debug/sample ./examples/configurations/alice.yml Node public key: 033ef46ab0d0fc2d2fbee8d4e105e9a1f12bd12812ab3d81a169242e6f68292ee1

offercontract 033ef46ab0d0fc2d2fbee8d4e105e9a1f12bd12812ab3d81a169242e6f68292ee1@127.0.0.1:9000 ./examples/contracts/numerical_contract_input.json Checking for messages bitcore wallet thread 'tokio-runtime-worker' panicked at sample/src/cli.rs:202:38: Error sending offer: WalletError(RpcError(JsonRpc(Rpc(RpcError { code: -11, message: "No addresses with label d411a6ba677fb62a66a90d6298757e8327f72375c913a63b686ecd158adcab01", data: None })))) note: run with RUST_BACKTRACE=1 environment variable to display a backtrace thread 'main' panicked at sample/src/cli.rs:215:22: called Result::unwrap() on an Err value: JoinError::Panic(Id(25), ...)

What is the reason for this?

h10086733 commented 6 months ago
fn derive_contract_signer(&self, keys_id: [u8; 32]) -> Result<Self::Signer, ManagerError> {
    println!("bitcore wallet");
    let label_map = self
        .client
        .lock()
        .unwrap()
        .call::<HashMap<Address<NetworkUnchecked>, Value>>(
            "getaddressesbylabel",
            &[Value::String(keys_id.to_lower_hex_string())],
        )
        .map_err(rpc_err_to_manager_err)?;

Is it feasible for me to successfully access the randomly generated keys_id by changing it to "bech32"?

fn get_new_change_address(&self) -> Result<Address, ManagerError> {
    println!("get_new_change_address ");
    Ok(self
        .client
        .lock()
        .unwrap()
        .call::<Address<NetworkUnchecked>>(
            "getrawchangeaddress",
            &[Value::Null, opt_into_json(Some(AddressType::Bech32))?],
        )
        .map_err(rpc_err_to_manager_err)?
        .assume_checked())
}

In addition, when I call getrawchangeaddress, it will call the data from the local main network. I changed it to rpc method and the request passed the test. Can I modify it like this?

Fn get_new_change.address (&self) ->Result<Address, ManagerError>{

Ok (self

. client

. lock()

. unwrap()

. get_raw_change.address (Some (AddressType: Bech32))

. map_err (rpc_err_to_manager_err)?

. assume_checked()

}

Tibo-lg commented 6 months ago

What is the reason for this?

Hard to say, maybe try to delete the data folder for both parties (should be called dlc_sample_alice and dlc_sample_bob) and try again see if it fixes it?

Also not sure I understand your other question, but I just realized that the tests for the sample are not set up as they should so I'll fix that and see if there is any issue.

Tibo-lg commented 6 months ago

@h10086733 I could reproduce the issue I will work on fixing it.

Tibo-lg commented 6 months ago

@h10086733 Can you check the branch from PR #210? I think it should fix the issues you had.

h10086733 commented 6 months ago

@h10086733 Can you check the branch from PR #210? I think it should fix the issues you had.

Well done! Thanks