Open remyers opened 10 months ago
It appears that an event type 4 (aps_create_tx_internal
) sets change_pos to 0 if the APS (avoid partial spends) attempt finds a solution without a change output. Should the simulation be run without APS? otherwise it seems like 0 is a valid change position result for a aps_create_tx_internal
Actually it seems like when event type 2 ( normal_create_tx_internal ) has no change output, but returns change_pos as 0 that that is triggering the assert. I'm still not sure why others haven't seen this problem. Did something changed in bitcoin?
Ah, that looks like a bug in Bitcoin Core. The return value for change position was changed from an int to an optional, but it is still being output as an int in a few places, like here. The conversion seems to be wrong, I think that's supposed to be a -1 rather than 0.
Thanks for the confirmation! I will suggest these fixups in @murchandamus 's coingrinder PR after it is rebased. It doesn't seem worth a stand alone PR to core. In the mean time I can make the changes locally so my simulations run.
I’d expect the fix to an outright bug like that get merged easily, and it might be better to fix separately, since CoinGrinder doesn’t seem to be on many people’s priorities, it’s been open since July.
Bitcoin version: master (c80f57ba5) coin-selection-simulation: main (c604fad)
I'm getting an assert because the change position is not null, but the tx has only one output. I'm not sure how to debug this further. Any suggestions?
I added some debugging lines and it looks like before the assert the state is:
event 2 success= 1 fee= 600 change_pos= 0
event 4 change_aps= 1 success= 1 fee= 600 change_pos= 0
len(dec["tx"]["vout"])= 1 change_pos= 0
dec["tx"]={'txid': '6ab21c3263e3c39d9b4abf1e34d40503f8e171ea5f089962ad81e7d0070c67c5', 'hash': '6ab21c3263e3c39d9b4abf1e34d40503f8e171ea5f089962ad81e7d0070c67c5', 'version': 2, 'size': 82, 'vsize': 82, 'weight': 328, 'locktime': 0, 'vin': [{'txid': '453c271c91d8f159d79c73f314069c9a8cd5aa769c591e9b42c66f8e1ff59934', 'vout': 0, 'scriptSig': {'asm': '', 'hex': ''}, 'sequence': 4294967293}], 'vout': [{'value': Decimal('0.00329000'), 'n': 0, 'scriptPubKey': {'asm': '0 727e19b73e721b43568abe335af127e957432da0', 'desc': 'addr(bcrt1qwflpnde7wgd5x452hce44uf8a9t5xtdqh2mkp9)#utql76pz', 'hex': '0014727e19b73e721b43568abe335af127e957432da0', 'address': 'bcrt1qwflpnde7wgd5x452hce44uf8a9t5xtdqh2mkp9', 'type': 'witness_v0_keyhash'}}]}