cryptonomex / graphene

MIT License
1.05k stars 336 forks source link

API get_required_signatures shouldn't return already signed key(s) #636

Closed abitmore closed 7 years ago

abitmore commented 8 years ago

The in-code document of get_required_signatures API says:

/**
*  This API will take a partially signed transaction and a set of public keys that the owner has the ability to sign for
*  and return the minimal subset of public keys that should add signatures to the transaction.
*/
set<public_key_type> get_required_signatures( const signed_transaction& trx, const flat_set<public_key_type>& available_keys )const;

If I understood correctly, when an unsigned transaction requires a signature of key A only, sign it with A, then call this API with the signed transaction as trx and A as available_keys, it should return an empty set. However, with latest version (2.0.160316b), the API returns a set contains A. Same behavior is found with earlier versions.

Log of a test on live BTS chain:

> {"id":1, "method":"call", "params":[0,"get_block",[4664932]]}
< {"id":1,"result":{"previous":"00472e6309ca15b5262dedd62e1e5f882fc6ee5e","timestamp":"2016-03-24T22:18:57","witness":"1.6.37","transaction_merkle_root":"68127a9be60e4e10616e45868d31ca3014930ba7","extensions":[],"witness_signature":"206dc384a063d35469ef2a55f5e2f9cc3223f18337c343cb7ab2220eb3f638887964c56aa726b1b26174ca538c717b543167854a5bacb9e35395b62543437534a5","transactions":[{"ref_block_num":11875,"ref_block_prefix":3038104073,"expiration":"2016-03-24T22:19:09","operations":[[2,{"fee":{"amount":1467,"asset_id":"1.3.0"},"fee_paying_account":"1.2.103955","order":"1.7.192217","extensions":[]}]],"extensions":[],"signatures":["1f1239bcbe2e5270f5fc672f133b34fc25dc074474d38733fac452b8b2e8a2c03f669d5c15b267839c02aec67bfa064b482a62cb9c3f94145368edc362887288ee"],"operation_results":[[2,{"amount":3100000,"asset_id":"1.3.933"}]]}]}}
> {"id":2, "method":"call", "params":[0,"get_potential_signatures",[{"ref_block_num":11875,"ref_block_prefix":3038104073,"expiration":"2016-03-24T22:19:09","operations":[[2,{"fee":{"amount":1467,"asset_id":"1.3.0"},"fee_paying_account":"1.2.103955","order":"1.7.192217","extensions":[]}]],"extensions":[],"signatures":[]}]]}
< {"id":2,"result":["BTS5sLyeb6CzkW1MGXgDQRa1xNVcaFeN9aSD1K4V9CyebNS8bBxMs"]}
> {"id":3, "method":"call", "params":[0,"get_required_signatures",[{"ref_block_num":11875,"ref_block_prefix":3038104073,"expiration":"2016-03-24T22:19:09","operations":[[2,{"fee":{"amount":1467,"asset_id":"1.3.0"},"fee_paying_account":"1.2.103955","order":"1.7.192217","extensions":[]}]],"extensions":[],"signatures":["1f1239bcbe2e5270f5fc672f133b34fc25dc074474d38733fac452b8b2e8a2c03f669d5c15b267839c02aec67bfa064b482a62cb9c3f94145368edc362887288ee"]},["BTS5sLyeb6CzkW1MGXgDQRa1xNVcaFeN9aSD1K4V9CyebNS8bBxMs"]]]}
< {"id":3,"result":["BTS5sLyeb6CzkW1MGXgDQRa1xNVcaFeN9aSD1K4V9CyebNS8bBxMs"]}
vikramrajkumar commented 7 years ago

This issue was moved to bitshares/bitshares-core#200