How to create pset with issuance
Hello,
I'm trying to use the CLI to create a pset (v2 format) in order to issue a new asset. For simplicity, I'm going for a fully unblinded pset. These are my steps:
$ e1 sendtoaddress ${issuer_unconf_addr_1} 1
$ e1 generatetoaddress 1 $(e1 getnewaddress)
# fund the issuer and retrie ${issuer_utxp_txid} and ${issuer_utxo_vout}
$ e1 calculateasset ${issuer_utxo_txid} ${issuer_utxo_vout} 0000000000000000000000000000000000000000000000000000000000000000 false
# retrieve ${issued_asset} and ${issued_token}
$ e1 walletcreatefundedpsbt '[{"txid": "${issuer_utxo_txid}", "vout": ${issuer_utxo_vout}, "asset_entropy": "0000000000000000000000000000000000000000000000000000000000000000", "issuance_amount": 1000, "issuance_tokens": 1, "blind_reissuance": false}]' '[{"${issuer_unconf_addr_1}": 0.00001, "asset": "${issued_asset}"}, {"${issuer_unconf_addr_2}": 0.00000001, "asset": "${issued_token}"}]'
This always produces the error:
error code: -4
error message:
Insufficient funds
Can someone help me figuring out what's wrong with this?
Thanks for filing this.
What version of Elements are you using? I notice that you tagged this GUI but the issue is about CLI commands -- can you confirm this this only a problem with the CLI?
Yeah, sorry about that, i didn't notice the label was already there when I opened the issue.. this is relative to the CLI, not related to GUI.
I'm running version: Elements Core RPC client version elements-0.21.0.1
I managed to create the pset with the help of converttopsbt, so basically I created a raw transaction, added the issuance with rawissueasset and then converted the tx into a psbt with the mentioned command.
This is the starting raw transaction:
0200000000012eb32f6b3c12cbfd4f5606b38c483b5524eaea9641163037accccafa5b14a8020000008000ffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000005f5e100010000000005f5e100040125b251070e29ca19043cf33ccd7324e2ddab03ecc4ae0b5e77c4fc0e5cf6c95a010000000005f5df0c001600147a4db0ce86add464d7c04b62e927b779a075a2f3018eab18d5dca3f0ae0982555e2e409d07173c34ec982ab92b15d5b8f04a4394de010000000005f5e10000160014afe88e699502468295549097b77e26b4faaa6ff401548385f9c6edc67235258118d039c3f4281a80894ca93e51ab7e43e5e99a4446010000000005f5e10000160014bc1120c5ede03d9b6934aa832643379082d32a870125b251070e29ca19043cf33ccd7324e2ddab03ecc4ae0b5e77c4fc0e5cf6c95a0100000000000001f4000000000000
This is my finalized pset:
cHNldP8BAgQCAAAAAQMEAAAAAAEEAQEBBQEEAfsEAgAAAAABAOQCAAAAAAGbud8KDBvUdk5KogGjV/Q/7A0mg1mzpbO9q0FkPh2lEgAAAAAA/f///wMBJbJRBw4pyhkEPPM8zXMk4t2rA+zErgted8T8Dlz2yVoBAAAAAAX14QAAFgAUr+iOaZUCRoKVVJCXt34mtPqqb/QBJbJRBw4pyhkEPPM8zXMk4t2rA+zErgted8T8Dlz2yVoBAAd18FQRXuoAFgAUbRMQ2l7bqF93wXvtAych3tvmUskBJbJRBw4pyhkEPPM8zXMk4t2rA+zErgted8T8Dlz2yVoBAAAAAAAAABYAAAEAAAABAUIBJbJRBw4pyhkEPPM8zXMk4t2rA+zErgted8T8Dlz2yVoBAAAAAAX14QAAFgAUr+iOaZUCRoKVVJCXt34mtPqqb/QBCGsCRzBEAiBtXgpm7tIqCdEo88OpXnr/8dNCJoYy3bQmJFsuIJOEvwIgeGffiXxIIa06lAIErWPCe1Bf6Gqaup3KHAwcATUfubIBIQP6TB8Q0HdG1lc4+RqebCy8HhVCXLP/zeuEJdady4blUwEOIC6zL2s8Esv9T1YGs4xIO1Uk6uqWQRYwN6zMyvpbFKgCAQ8EAAAAAAEQBP////8H/ARwc2V0AAgA4fUFAAAAAAf8BHBzZXQKCADh9QUAAAAAACICAqJdVv/gCiIrb2goUkOlzvnqGmfS9CQFscvTQhNTMOy/EP/sZTsAAACAAAAAgCgAAIABBBYAFHpNsM6GrdRk18BLYuknt3mgdaLzAQMIDN/1BQAAAAAH/ARwc2V0AiAlslEHDinKGQQ88zzNcyTi3asD7MSuC153xPwOXPbJWgf8BHBzZXQIBAAAAAAAIgID+kwfENB3RtZXOPkanmwsvB4VQlyz/83rhCXWncuG5VMQ/+xlOwAAAIAAAACAAQAAgAEEFgAUr+iOaZUCRoKVVJCXt34mtPqqb/QBAwgA4fUFAAAAAAf8BHBzZXQCII6rGNXco/CuCYJVXi5AnQcXPDTsmCq5KxXVuPBKQ5TeB/wEcHNldAgEAAAAAAAiAgIXtDw2QPv1PK38KZ1ulQWElh62mjFQQoWYqvlSAzslTRD/7GU7AAAAgAAAAIACAACAAQQWABS8ESDF7eA9m2k0qoMmQzeQgtMqhwEDCADh9QUAAAAAB/wEcHNldAIgVIOF+cbtxnI1JYEY0DnD9CgagIlMqT5Rq35D5emaREYH/ARwc2V0CAQAAAAAAAEEAAEDCPQBAAAAAAAAB/wEcHNldAIgJbJRBw4pyhkEPPM8zXMk4t2rA+zErgted8T8Dlz2yVoH/ARwc2V0CAQAAAAAAA==
And this is the raw tx extracted with finalizepsbt:
0200000001012eb32f6b3c12cbfd4f5606b38c483b5524eaea9641163037accccafa5b14a8020000000000ffffffff040125b251070e29ca19043cf33ccd7324e2ddab03ecc4ae0b5e77c4fc0e5cf6c95a010000000005f5df0c001600147a4db0ce86add464d7c04b62e927b779a075a2f3018eab18d5dca3f0ae0982555e2e409d07173c34ec982ab92b15d5b8f04a4394de010000000005f5e10000160014afe88e699502468295549097b77e26b4faaa6ff401548385f9c6edc67235258118d039c3f4281a80894ca93e51ab7e43e5e99a4446010000000005f5e10000160014bc1120c5ede03d9b6934aa832643379082d32a870125b251070e29ca19043cf33ccd7324e2ddab03ecc4ae0b5e77c4fc0e5cf6c95a0100000000000001f400000000000000000247304402206d5e0a66eed22a09d128f3c3a95e7afff1d342268632ddb426245b2e209384bf02207867df897c4821ad3a940204ad63c27b505fe86a9aba9dca1c0c1c01351fb9b2012103fa4c1f10d07746d65738f91a9e6c2cbc1e15425cb3ffcdeb8425d69dcb86e553000000000000000000
If you decode them, you can see:
- the input of the starting raw tx has the issuance set
- the input of the pset has issuance amounts
- the input of the extraced raw tx is missing the issuance and, in fact, the tx does not get broadcasted with
sendrawtransactionwith the errorerror code: -26 error message: bad-txns-in-ne-out, value in != value out
I tried the PSBT commands (converttopsbt, walletprocesspsbt, finalizepsbt) and got the same result (problem). The problem seems to be with finalizepsbt.
https://github.com/ElementsProject/elements/blob/elements-0.21.0.1/src/psbt.cpp#L126-L132
- It would be better to match the following implementation of txout.
- https://github.com/ElementsProject/elements/blob/elements-0.21.0.1/src/psbt.cpp#L140-L152
- It seems that
txin.assetIssuance.nAmountandtxin.assetIssuance.nInflationKeysshould be judged separately. Because in the case of reissuance, onlytxin.assetIssuance.nAmountis used.