You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @alexqrid! Nice find, normally pegins have explicit (unblinded) outputs.
I'm wondering why its amount is confidential, if the output of BTC transaction is not confidential?
The output on the liquid side can be blinded, but obviously not on the bitcoin side.
so why the node is not returning amount of this peg-in input, if we can get it from the BTC output?
Only the wallet that created the output has the blinding keys (unless they get exported and shared), and the output asset/amount can't be unblinded without the blinding keys.
The transaction has two confidential outputs, so in principle, the pegin amount could be split in any way between the two, and there's no way to tell :).
In practice because one output is OP_RETURN, I think we can assume that its value is 0 and the entire pegin went to the other output.
I think that the Elements wallet will do this if you do a peg-in to a confidential address.
I would like to know how to construct such a blinded pegin transaction using the RPC calls. Please help me.
UPDATE: Just want to sum up all the ways that did not work: using just a long CT address in a pegin and then calling blindrawtransaction did not help. Neither did rawblindraw transaction with dest addr blindingkey, value, default Bitcoin asset and all-zero asset blinding key. Neither flipping the last and first of previous. No more ideas at the moment. The transaction skeleton I use for experimenting looks the same as above'linket tx, i.e. data ("deadbeef") followed by hmm. Createrawtransaction reorders vout to destination address and fee. I will try to form a raw hex instead.
@apoelstra My finding is that Elements wallet does not do such transaction by itself. So far, at least. Maybe GUI? But I doubt since claimpegin has to be manually called also in the GUI (tried in January this year).
As a general rule, you should use the PSET API rather than the rawtransaction API ... though for a single-party transaction both should be fine.
The "automatically add OP_RETURN" behavior happens in CreateTransaction (actually, in fillBlindDetails if you want to do a deep dive into the source code) which appears only to be called from the sendtoaddress, sendmany, fundrawtransaction or walletcreatefundedpsbt RPCs.
So I think the RPC you need to call is fundrawtransaction. You need to make sure that there is only one output to blind and that at least one of your inputs is a CT input. If you have no CT inputs but a blinded destination, the logic will either fail or unblind the blinded destination (which is insane but that's what I see in the logic).
(This is an obscure corner of the blinding logic and it may be helpful to look at the fillBlindDetails source in src/wallet/spend.cpp to see what is going on. Much of this code has become crufty and incoherent as it has been rebased over multiple Bitcoin Core releases, we have added PSET support, etc. I have a long-term goal to rewrite the whole thing but it's a huge task and I have no ETA.)
The output hex from createrawtransaction is piped straight into fundrawtransaction which produces following (shall be reproducible everywhere with these inputs)
Note the first vout is from the first input, the second vout uses the rest of the on-chain peg-in UTXO sats (instead of OP_RETURN but same purpose to allow blinding later).
The vsize of the signed and blinded transaction as reported by decoderawtransaction is 2674. But that is NOT what we are looking for. The discountvsize is 525. That means the minimal possible discounted fee with Liquid fee-rate of 0.1 sat/vB would be 53 sats and when discounted CT fees (0.01 sat/vB) are live, the minimal fee for this transaction will be 27 sats. How to adjust the transaction to use merely the lowest fee is left as a food for thought.
Thanks for pushing through on this! Glad you solved it.
These "blinding logic does unexpected/confusing things" issues always make me wince a little :).
As for getting the wallet to use the reduced fees, I am not sure what the status of that is. It looks like we just cut a release with the reduced fees in it a couple days ago #1337 but I don't recall if it needs any config flags to be set or what.
Yes, even though it is in the code, the reduced fees will not be available for general use until minrelaytxfee is also adjusted (to 0.0000001 now, there is one more non-zero, i.e. spam-limiting, step for the future). It can be done on any node but there is currently no federation node facing outside to relay the discounted fee CT to a block-signer I think. But this will pass eventually.
There is another option enabling Elements wallet to use discounted CTs, creatediscountct=1, but it does not enable such low-fee transaction relaying even if enabled. In other words the discounted CT does not even get from the wallet to the local node's mempool with the default settings and this option enabled. If and when such transaction gets into a block shall be revealed by a new canary which is fully known at least to one well-connected Elements node at the moment and I hope for a fair relaying that will show general availability for all rather than submitting it to miner by other channels which can be done and was an appreciated step.
And yes, also createpsbt works instead of createrawtransaction here! Thanks!
UPDATE: New canary link. The old one was not paying enough fees because it used vsize to compute the minimal fee rather than discountvsize)
reduced fees will not be available for general use until minrelaytxfee is also adjusted
not exactly correct: once the new release is rolled out on liquidv1 with accept_discount_ct=1, it will be possible to relay a discounted CT at a nominal feerate of 0.1 sats/vb (having a lower real feerate), as long as your node can relay to other "accept" nodes all the way to the blocksigners.
it's not necessary (nor planned afaik) to reduce the minrelayfee default for liquidv1
One more example here for the record. It is a confidential transaction containing two pegins and one previously blinded UTXO on the inputs side and two blinded halves on the output side. Pays a minimum fee at fee-rate 0.1 sat/vB. Already blinded and signed, just that the pegins are both claimed so there is no point in trying to broadcast it (but feel free to try).
reduced fees will not be available for general use until minrelaytxfee is also adjusted
not exactly correct: once the new release is rolled out on liquidv1 with accept_discount_ct=1, it will be possible to relay a discounted CT at a nominal feerate of 0.1 sats/vb (having a lower real feerate), as long as your node can relay to other "accept" nodes all the way to the blocksigners.
it's not necessary (nor planned afaik) to reduce the minrelayfee default for liquidv1
Activity
delta1 commentedon Apr 5, 2024
Hey @alexqrid! Nice find, normally pegins have explicit (unblinded) outputs.
The output on the liquid side can be blinded, but obviously not on the bitcoin side.
Only the wallet that created the output has the blinding keys (unless they get exported and shared), and the output asset/amount can't be unblinded without the blinding keys.
apoelstra commentedon Apr 5, 2024
The transaction has two confidential outputs, so in principle, the pegin amount could be split in any way between the two, and there's no way to tell :).
In practice because one output is OP_RETURN, I think we can assume that its value is 0 and the entire pegin went to the other output.
I think that the Elements wallet will do this if you do a peg-in to a confidential address.
jsarenik commentedon Jun 17, 2024
I would like to know how to construct such a blinded pegin transaction using the RPC calls. Please help me.
UPDATE: Just want to sum up all the ways that did not work: using just a long CT address in a pegin and then calling blindrawtransaction did not help. Neither did rawblindraw transaction with dest addr blindingkey, value, default Bitcoin asset and all-zero asset blinding key. Neither flipping the last and first of previous. No more ideas at the moment. The transaction skeleton I use for experimenting looks the same as above'linket tx, i.e. data ("deadbeef") followed by hmm. Createrawtransaction reorders vout to destination address and fee. I will try to form a raw hex instead.
jsarenik commentedon Jun 17, 2024
@apoelstra My finding is that Elements wallet does not do such transaction by itself. So far, at least. Maybe GUI? But I doubt since
claimpeginhas to be manually called also in the GUI (tried in January this year).apoelstra commentedon Jun 17, 2024
As a general rule, you should use the PSET API rather than the rawtransaction API ... though for a single-party transaction both should be fine.
The "automatically add OP_RETURN" behavior happens in
CreateTransaction(actually, infillBlindDetailsif you want to do a deep dive into the source code) which appears only to be called from thesendtoaddress,sendmany,fundrawtransactionorwalletcreatefundedpsbtRPCs.So I think the RPC you need to call is
fundrawtransaction. You need to make sure that there is only one output to blind and that at least one of your inputs is a CT input. If you have no CT inputs but a blinded destination, the logic will either fail or unblind the blinded destination (which is insane but that's what I see in the logic).(This is an obscure corner of the blinding logic and it may be helpful to look at the
fillBlindDetailssource in src/wallet/spend.cpp to see what is going on. Much of this code has become crufty and incoherent as it has been rebased over multiple Bitcoin Core releases, we have added PSET support, etc. I have a long-term goal to rewrite the whole thing but it's a huge task and I have no ETA.)jsarenik commentedon Jun 18, 2024
Success! For record I will write one possibility here done with Elements Core v23.2.2rc2
fundrawtransactionwill be used as suggested above, but for practice and better understanding I suggest trying at least one of the other options.Let's say we have following input for
createrawtransaction:[{"txid":"7007f1091b6a3e973316416a67c249993f2799a34219dbed49129bbb70d80345","vout":0,"pegin_bitcoin_tx":"02000000000101b4c4c57794d37d086ab47cdf7004e91ca2a45ae9428dba541259516682e6f1ca0200000000fdffffff0240420f00000000002200204ec0a83d897cfa7637a7e2096983f34e711e94477ee9421463d872ba8da789236d3a7f0000000000160014014e8cbae2c9038a1b917d5a05ff9435a7702fd002473044022006a79295b35f41f39b1daddf570d201025146c34e7f0ad073244f8288a0dbc52022056d0532ad82c6b369360f22dadd725084d12374fdaa8b47a936bc3770c6b26a50121026cb93a5de74af745b87226cae67728de53be46f53e77a0f88b57bf4dcfdc684900000000","pegin_txout_proof":"004049259e57878af7850e5f4e9b6785070d3b291519a3e93cee000000000000000000006ada04f732c3aa582769f204cb14ba8ffbfd8cb1c4eb2be17c55cf0ac3ec5f0b04236e66b85c03178c16665eca0a00000dd10abab181486ee71f7bfb7d3764f2c994a5df7e49ff0e67fa553189fb400be86afc6e9bd9f9c874ce28ecce173dfddd7fe616180d6d941c872b1dcab95fd89934d035b5c0cdf795dfa10dbf677507536401272e24bbae022b825b548aa1a0899c738806994355104be7931644d94f2dd17bda1117cec20b4142dc7cce0c31694503d870bb9b1249eddb1942a399273f9949c2676a411633973e6a1b09f10770a8753ebf3cae831a182a92b1e27dc7fd004724f76803229a3d7f7ebe538b8a6328621291afc2738606af6db0e65425d8619c785afa37e51bffa4e8f08069bc6b73a6caf4d996262fede1810a19afa2355ad8f518fe21e293d47e7ffe530ef13d53561e6cba304957d495e29e51856bba4cade71cf89d0931585d0d8a5e34c916a002b6efb143c5677be5517cd76a2e15924a052612d16a4d2046d1749914fd69618508d11791b3b5ce6231c42e7ac2a84a3ee07ab816c372e6b2c4cfff15942ff93739d443f4feb52517fc37054998d976865bdb9cb1390991d4f76e15ad7a492428e0efdf75ae483e0201a8e3a7a1bc3b0c44c58283dc09499115392d122aae04ebbe0100","pegin_claim_script":"00144ec129dac74f72573aa560e89b3550db9b8965aa"}] [{"lq1qqv86249zsxdtvg35r5qy5lew6q5t05l05ucxq8lpx7zeagx58qk0eadtqjvjp0dl8gz6le4pe7mrsgt55rsgknsz9shdq249x":0.00599900}]The output hex from
createrawtransactionis piped straight intofundrawtransactionwhich produces following (shall be reproducible everywhere with these inputs)For comprehension here is the decoded raw transaction JSON:
{ "txid": "3f54840b91145bbec0b905c167cb6cb3ab394422e381ce7770405ab05e7b876a", "hash": "b4793502ed5097eff5b9c2923c11405b8fa817ad639d8dd92a55b087ecaf4135", "wtxid": "b4793502ed5097eff5b9c2923c11405b8fa817ad639d8dd92a55b087ecaf4135", "withash": "14f8528f927b76bc40a5ddc0c456bc0c86c5c24cbef8ff91e92c9f5e30273372", "version": 2, "size": 1035, "vsize": 478, "weight": 1911, "locktime": 0, "vin": [ { "txid": "7007f1091b6a3e973316416a67c249993f2799a34219dbed49129bbb70d80345", "vout": 0, "scriptSig": { "asm": "", "hex": "" }, "is_pegin": true, "sequence": 4294967295, "pegin_witness": [ "40420f0000000000", "6d521c38ec1ea15734ae22b7c46064412829c0d0579f0a713d1c04ede979026f", "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000", "00144ec129dac74f72573aa560e89b3550db9b8965aa", "0200000001b4c4c57794d37d086ab47cdf7004e91ca2a45ae9428dba541259516682e6f1ca0200000000fdffffff0240420f00000000002200204ec0a83d897cfa7637a7e2096983f34e711e94477ee9421463d872ba8da789236d3a7f0000000000160014014e8cbae2c9038a1b917d5a05ff9435a7702fd000000000", "004049259e57878af7850e5f4e9b6785070d3b291519a3e93cee000000000000000000006ada04f732c3aa582769f204cb14ba8ffbfd8cb1c4eb2be17c55cf0ac3ec5f0b04236e66b85c03178c16665eca0a00000dd10abab181486ee71f7bfb7d3764f2c994a5df7e49ff0e67fa553189fb400be86afc6e9bd9f9c874ce28ecce173dfddd7fe616180d6d941c872b1dcab95fd89934d035b5c0cdf795dfa10dbf677507536401272e24bbae022b825b548aa1a0899c738806994355104be7931644d94f2dd17bda1117cec20b4142dc7cce0c31694503d870bb9b1249eddb1942a399273f9949c2676a411633973e6a1b09f10770a8753ebf3cae831a182a92b1e27dc7fd004724f76803229a3d7f7ebe538b8a6328621291afc2738606af6db0e65425d8619c785afa37e51bffa4e8f08069bc6b73a6caf4d996262fede1810a19afa2355ad8f518fe21e293d47e7ffe530ef13d53561e6cba304957d495e29e51856bba4cade71cf89d0931585d0d8a5e34c916a002b6efb143c5677be5517cd76a2e15924a052612d16a4d2046d1749914fd69618508d11791b3b5ce6231c42e7ac2a84a3ee07ab816c372e6b2c4cfff15942ff93739d443f4feb52517fc37054998d976865bdb9cb1390991d4f76e15ad7a492428e0efdf75ae483e0201a8e3a7a1bc3b0c44c58283dc09499115392d122aae04ebbe0100" ] } ], "vout": [ { "value": 0.00599900, "asset": "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d", "commitmentnonce": "030fa554a2819ab622341d004a7f2ed028b7d3efa730601fe137859ea0d4382cfc", "commitmentnonce_fully_valid": true, "n": 0, "scriptPubKey": { "asm": "0 f5ab049920bdbf3a05afe6a1cfb6382174a0e08b", "desc": "addr(ex1q7k4sfxfqhkln5pd0u6suld3cy962pcytrtl3vc)#g67hzxel", "hex": "0014f5ab049920bdbf3a05afe6a1cfb6382174a0e08b", "address": "ex1q7k4sfxfqhkln5pd0u6suld3cy962pcytrtl3vc", "type": "witness_v0_keyhash" } }, { "value": 0.00400065, "asset": "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d", "commitmentnonce": "02245d65f2a57de9cdf9f2d4c21389f5119bc67435b274cec956b4013a7c883e1b", "commitmentnonce_fully_valid": true, "n": 1, "scriptPubKey": { "asm": "0 6076ff79c5d0dd18fd5e2517fc74b804ced5c178", "desc": "addr(ex1qvpm077w96rw33l27y5tlca9cqn8dtstccc5x4h)#wayhhgha", "hex": "00146076ff79c5d0dd18fd5e2517fc74b804ced5c178", "address": "ex1qvpm077w96rw33l27y5tlca9cqn8dtstccc5x4h", "type": "witness_v0_keyhash" } }, { "value": 0.00000035, "asset": "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d", "commitmentnonce": "", "commitmentnonce_fully_valid": false, "n": 2, "scriptPubKey": { "asm": "", "desc": "raw()#58lrscpx", "hex": "", "type": "fee" } } ], "fee": { "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d": 0.00000035 } }Note the first
voutis from the first input, the secondvoutuses the rest of the on-chain peg-in UTXO sats (instead of OP_RETURN but same purpose to allow blinding later).Now let's sign the transaction:
Now blind it:
The
vsizeof the signed and blinded transaction as reported bydecoderawtransactionis 2674. But that is NOT what we are looking for. Thediscountvsizeis 525. That means the minimal possible discounted fee with Liquid fee-rate of 0.1 sat/vB would be 53 satsand when discounted CT fees (0.01 sat/vB) are live, the minimal fee for this transaction will be 27 sats. How to adjust the transaction to use merely the lowest fee is left as a food for thought.Thanks to @apoelstra for ideas!
UPDATE: Fallacy with not using
discountvsizebut rather dividingvsizeby 100 fixed (see strikethrough text)UPDATE2: Blinding shall be done before signing.
apoelstra commentedon Jun 18, 2024
Thanks for pushing through on this! Glad you solved it.
These "blinding logic does unexpected/confusing things" issues always make me wince a little :).
As for getting the wallet to use the reduced fees, I am not sure what the status of that is. It looks like we just cut a release with the reduced fees in it a couple days ago #1337 but I don't recall if it needs any config flags to be set or what.
jsarenik commentedon Jun 18, 2024
Yes, even though it is in the code, the reduced fees will not be available for general use untilminrelaytxfeeis also adjusted (to0.0000001now, there is one more non-zero, i.e. spam-limiting, step for the future). It can be done on any node but there is currently no federation node facing outside to relay the discounted fee CT to a block-signer I think. But this will pass eventually.There is another option enabling Elements wallet to use discounted CTs,If and when such transaction gets into a block shall be revealed by a new canary which is fully known at least to one well-connected Elements node at the moment and I hope for a fair relaying that will show general availability for all rather than submitting it to miner by other channels which can be done and was an appreciated step.creatediscountct=1, but it does not enable such low-fee transaction relaying even if enabled. In other words the discounted CT does not even get from the wallet to the local node's mempool with the default settings and this option enabled.And yes, also
createpsbtworks instead ofcreaterawtransactionhere! Thanks!UPDATE: New canary link. The old one was not paying enough fees because it used
vsizeto compute the minimal fee rather thandiscountvsize)delta1 commentedon Jun 19, 2024
not exactly correct: once the new release is rolled out on liquidv1 with
accept_discount_ct=1, it will be possible to relay a discounted CT at a nominal feerate of 0.1 sats/vb (having a lower real feerate), as long as your node can relay to other "accept" nodes all the way to the blocksigners.it's not necessary (nor planned afaik) to reduce the minrelayfee default for liquidv1
jsarenik commentedon Jun 19, 2024
One more example here for the record. It is a confidential transaction containing two pegins and one previously blinded UTXO on the inputs side and two blinded halves on the output side. Pays a minimum fee at fee-rate 0.1 sat/vB. Already blinded and signed, just that the pegins are both claimed so there is no point in trying to broadcast it (but feel free to try).
Decode yourself using
decoderawtransactionelements-cli RPC. Decoded and shortened:{ "txid": "b0a80e552dcbf310f60457e22a2ede0e5ed6442a9c0e95359cec567072b65789", "hash": "8d9c58808cb04bd8523bd9e7ee252b9480f1d4732ae5b25285548502c86ad917", "wtxid": "8d9c58808cb04bd8523bd9e7ee252b9480f1d4732ae5b25285548502c86ad917", "withash": "88eb8d0e74b448d836c3b27a939e375411e6fe2ecb235236828e7faf18591805", "version": 2, "size": 10982, "vsize": 3062, "weight": 12248, "locktime": 0, "vin": [ { "txid": "7007f1091b6a3e973316416a67c249993f2799a34219dbed49129bbb70d80345", "vout": 0, "is_pegin": true 8< SNIP ... shortened here >8 }, { "txid": "d5b502053e0780a1f12517a2533ae5a106b330c8bd34b6d9664cbb43d86ec326", "vout": 0, "is_pegin": true 8< SNIP ... shortened here >8 }, { "txid": "91985d5b5d6c6bdbd5a1ed23b6c2120eea7654bea1ed07b3f5c0c9f64bd51d99", "vout": 0, "is_pegin": false 8< SNIP ... shortened here >8 }, ], "vout": [ { "value-minimum": 0.00000001, "value-maximum": 45035996.27370496, "ct-exponent": 0, "ct-bits": 52, "commitmentnonce_fully_valid": true 8< SNIP ... shortened here >8 }, { "value-minimum": 0.00000001, "value-maximum": 45035996.27370496, "ct-exponent": 0, "ct-bits": 52, "commitmentnonce_fully_valid": true 8< SNIP ... shortened here >8 }, { "value": 0.00000307, "asset": "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d", "commitmentnonce": "", "commitmentnonce_fully_valid": false 8< SNIP ... shortened here >8 } ], "fee": { "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d": 0.00000307 } }jsarenik commentedon Jun 19, 2024
Thank you @delta1 ! I finally see my fallacy!
I was using the
vsizedivided by 100, but what I shall look at isdiscountvsizedivided by 10 instead. Thanks!