How to fix BAD_AGGREGATE_SIGNATURE

I just learn official tutorial < Signatures in Chialisp>
link is : Signatures in Chialisp | Chia Network - YouTube

but i write wrong code and send some xch to it.

here is my chialisp code:

(mod (PUBLIC_KEY conditions)
    (include condition_codes.clib)
    (include sha256tree.clib)

    (c
        (list AGG_SIG_UNSAFE PUBLIC_KEY (sha256tree conditions))
        conditions
    )

)

and vedio correct code is use ‘AGG_SIG_ME’ not use ‘AGG_SIG_UNSAFE’

but I used, it did happen(sid)

and then, I use condition tree hash + coinid + Genesis Challenge to make signature for spend bundle.

but when I spend this coin the blockchian return bellow info:

(venv) anlish@t1:~/Desktop/code/chia-code/chialisp$ cdv rpc pushtx ~/Desktop/code/chia-code/chialisp/signature_spend_bundle.json
("{'error': 'Failed to include transaction "
 'f8f24b1cf6faa2871f3e3fc04a23ae57768cb106323fa72aa8a48047decc3712, error '
 "BAD_AGGREGATE_SIGNATURE', 'success': False}")

so, how should I retrieve this coin?

thank you very much !

For AGG_SIG_UNSAFE, you only need to sign the message without coin_id and GENESIS_CHALLENGE. So basically, just sign the hash you get from this step.

1 Like

yes, you’re right! actural i has been try to only sign the sha256 tree hash, but got the same error.

and when you answer my question, i recheck my code and find the bug:
in vedio is

opc -H "((51 0xb51f75c3632f78eabb3c6b060b9a49c2f04fef8b80e67718a91932f10af37817 10000000000))"

but my code is

opc -H "(((51 0xb51f75c3632f78eabb3c6b060b9a49c2f04fef8b80e67718a91932f10af37817 10000000000)))"

this bug let program throw BAD_AGGREGATE_SIGNATURE
fix it and try again got correct result.

thank you soooooooo much!

1 Like