Comments (15)
Yes, seems related to #19. Let's see will the fix there solve this issue as well
from rgb-node.
I am working on PSBT analysis tool in Bitcoin Pro which I will use to solve the problem
from rgb-node.
Thanks for reporting. Can you pls provide a full command line args you are using for doing the transfer? If you can, pls attach cache/assets.yaml
file from the daemon data directory.
from rgb-node.
Regarding the origin of the error, this seems to be right. Clearly it can't read public key from PSBT. Will investigate with the command line options you provide
from rgb-node.
Sure - the transfer:
i9n_rgb.runtime.transfer( vec![issue_outpoint], vec![change_outcoins], transfer_invoice, funded_psbt.psbt.clone(), consignment_file, transaction_file, );
issue_outpoint = OutPoint { txid: 7cf042e20ceb1e7772c34d3b0537a4507bf08e0221833d2cc5f35d1eff437900, vout: 0, }
change_outcoins = Outcoins { coins: 14.0, vout: 0, txid: Some( aa4016426ec257b7f76f8076f47e0db609ad396a9133432739a52eb29539210a, ), }
transfer_invoice = Invoice { contract_id: cd63f437d2ccb0d3d9052221c819da750c6e51f99f4faef0a1169f4da31e8f20, outpoint: BlindedUtxo( 17411af60bb2a927522789e2df69e56272a678912c10dd719566de57de06888a, ), amount: 14.0, }
assets.yaml here.
Two possible causes I've thought of:
-
For making the invoice, I saw that using an Outpoint derived from an address is not yet implemented. So instead I do:
let blind_hash = rgb::lnpbp::bp::blind::OutpointHash::from(outpoint);
let blind = fungible::Outpoint::BlindedUtxo(blind_hash);
I'm not sure if that is correct. -
I have been using an rgbd instance that is started with the network set to testnet, but I am using a regtest instance. IIRC this would cause address prefixes to be different / incompatible. I had trouble previously with getting rgbd to start with regtest as the chain / network, but I'll look into this more now.
from rgb-node.
Re: network mismatch between rgbd and bitcoind, I think I am running into some of the config issues brought up here.
Specifically, I am starting the rgb processes via i9n::Runtime::init
with threaded = true
. The rgb processes don't seem to register the network setting as regtest, for both states of threaded
. I observe the same behavior when starting rgbd from the command line.
from rgb-node.
I've updated to v0.2.0-beta.4, and rgb-node now registers the given regtest chain param, which is great.
However, I still have the same error from stash on transfer, so unsure what the root cause is.
from rgb-node.
For more information on the origin of the error:
-i9n::fungible, transfer method -> (RPC with TransferApi)
--contracts::fungible, rpc_transfer method -> (RPC with ConsignRequest)
---stash::fungible, rpc_consign method -> (transitions, PSBT)
----lnpbp::rgb::stash::anchor, commit function -> (PSBT output, "RGB", PSBT_OUT_PUBKEY)
-----lnpbp::bp::psbt, proprietary_key method
------lnpbp::paradigms, strict_decode function
Here we return lnpbp::paradigms::strict_encoding::Error
, and this propogates back up.
In anchor::commit, this error is mapped to lnpbp::rgb::stash::anchor::Error::WrongPubkeyData
.
The stash runtime wraps this in its RPC reply to the fungible runtime, which returns the final error message in the debug logs.
from rgb-node.
Ok, I found the reason of the issue (but not a solution yet). It's really wierd.
PSBT, when read from Base64 in i9n
, deserializes public key with two additional bytes in front (which represents the lengths of the record, 0x33, 0x00
). These two bytes are absent when PSBT is deserialized from binary file. Both deserializations call the same method from rust-bitcoin
, so this must not happen (but it happens though).
base64 deserialization: https://github.com/LNP-BP/rgb-node/blob/c3a15e92051f20009888e70dd77c88eb44768480/src/i9n/fungible.rs#L101
unknown: {Key { type_value: 254, key: [3, 82, 71, 66, 1] }: [33, 0, 3, 158, 255, 31, 84, 122, 29, 95, 146, 223, 162, 186, 122, 246, 172, 151, 26, 75, 208, 59, 164, 167, 52, 176, 49, 86, 162, 86, 184, 173, 58, 30, 249]} }] } }
binary deserialization: https://github.com/LNP-BP/rgb-node/blob/c3a15e92051f20009888e70dd77c88eb44768480/src/cli/fungible.rs#L462
unknown: {Key { type_value: 254, key: [3, 82, 71, 66, 1] }: [3, 158, 255, 31, 84, 122, 29, 95, 146, 223, 162, 186, 122, 246, 172, 151, 26, 75, 208, 59, 164, 167, 52, 176, 49, 86, 162, 86, 184, 173, 58, 30, 249]} }] }
Deserialization in i9n
calls deserialize
function to read from binary array https://github.com/rust-bitcoin/rust-bitcoin/blob/master/src/consensus/encode.rs#L163-L186, however this function just directly calls to consensus_decode
like cli
version: https://github.com/rust-bitcoin/rust-bitcoin/blob/master/src/util/psbt/mod.rs#L119
@rajarshimaitra may you help me looking into this, spend several hrs and still not being able to figure out how this could happen
from rgb-node.
The bug is clearly in rust-bitcoin; @rajarshimaitra I will ask you to help me finding it there. Currently made a workaround in RGB Node and the issue is closed here (we still need to file it to rust-bitcoin)
from rgb-node.
Filed a bug in rust-bitcoin rust-bitcoin/rust-bitcoin#532
from rgb-node.
Actually it seems my fix does not work either. So when we do a PartiallysignedTransaction::consensus_decode
for in-memory data (converted from Base64) we got different PSBT data structure than when we do the same PartiallysignedTransaction::consensus_decode
from a file, which is very, very weird
from rgb-node.
That is indeed very strange - I will try to replicate, let me know if I can help in some other way.
from rgb-node.
@dr-orlovsky, Noted. This looks interesting, I will dig it tonight.
from rgb-node.
@dr-orlovsky seems strange from my end. I tried to reproduce the behaviour as per your comment #102 (comment).
I have made this small test that is using the above two decoding methods to reproduce the behaviour
fn test1() {
// Test psbt encoding decoding from files and memory buffer
let file_name = "/rgb-node/sample/source_tx.psbt";
let psbt_file = File::open(file_name).unwrap();
// decode the PSBT file
let psbt_from_file = PartiallySignedTransaction::consensus_decode(psbt_file).unwrap();
// Same file but decoded into bytes
let mut psbt_file = File::open(file_name).unwrap();
let metadata = std::fs::metadata(&file_name).expect("unable to read metadata");
let mut psbt_bytes = vec![0; metadata.len() as usize];
psbt_file.read(&mut psbt_bytes).unwrap();
// decode PSBT from in-memory bytes
let psbt_from_bytes: PartiallySignedTransaction = deserialize(&psbt_bytes).unwrap();
// This equality ensures decoding in memory buffer and files are same
assert_eq!(psbt_from_bytes, psbt_from_file);
//test decoding from base64 to simulate the bug of same byte array
let base64_psbt = base64::encode(psbt_bytes);
let psbt_bytes_2 = base64::decode(base64_psbt).unwrap();
let psbt_from_bytes_2 : PartiallySignedTransaction = deserialize(&psbt_bytes_2).unwrap();
// This assertion ensures base64 decoding is also equal
assert_eq!(psbt_from_bytes, psbt_from_bytes_2);
}
This above is passing all the assertions. Still trying to reproduce the bug.
from rgb-node.
Related Issues (20)
- Release mode of the `rgbd` causes `TransitionNotInAnchor` HOT 1
- Release latest rgb_node 0.8.0 to crates.io HOT 4
- Fix TransferCommand::Combine CLI command (NoOutpoint error)
- Fix TransferCommand::Combine CLI command (index out of bounds error)
- consignment processing: node_ids should not collect genesis ID
- cannot spend assets moved with Blank transitions
- merge of merkle blocks anchored to the same TXID can fail HOT 11
- Expose metadata as part of the state HOT 1
- seal proofs are not verified HOT 12
- Move clone to a specific branch
- Support other state types as done in #212
- add the ability to stop a spawned thread HOT 3
- Bucketd ElectrumConnectivity connectivity error when spawned by contract register HOT 9
- Stuck on `Initializing runtime` HOT 2
- Currently this does not work... HOT 4
- Readme is not up to date HOT 1
- cargo install overflow evaluating HOT 7
- Unable to install rgb-node HOT 2
- Is there a public docker image provided? HOT 1
- problem when install RGB node HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rgb-node.