Skip to content

Commit

Permalink
Merge pull request #265 from Virus-Axel/bugfix/not_enough_signers
Browse files Browse the repository at this point in the history
Add error message for not enough signers
  • Loading branch information
Virus-Axel authored Aug 23, 2024
2 parents 7152cbf + 4d20df7 commit 8be5065
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ void Message::merge_account_meta(const AccountMeta &account_meta){
}

void Message::merge_signer(const Variant& signer){
ERR_FAIL_COND_EDMSG(Pubkey::is_pubkey(signer), "Pubkey is provided as signing parameter. (Use Keypair or WalletAdapter.)");

for(unsigned int i = 0; i < signers.size(); i++){
if(Pubkey::bytes_from_variant(signers[i]) == Pubkey::bytes_from_variant(signer)){
return;
Expand Down
4 changes: 4 additions & 0 deletions src/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ PackedByteArray Transaction::serialize_signers(){
}

Variant Transaction::sign_and_send(){
ERR_FAIL_COND_V_EDMSG(Object::cast_to<Message>(message)->get_signers().size() != signatures.size(), Error::ERR_UNCONFIGURED ,"Transaction does not have enough signers.");
connect("fully_signed", Callable(this, "send_and_disconnect"));

sign();
Expand Down Expand Up @@ -525,6 +526,9 @@ void Transaction::blockhash_callback(Dictionary params){

void Transaction::send(){
ERR_FAIL_COND_EDMSG(!is_inside_tree(), "Transaction node must be added to scene tree.");

ERR_FAIL_COND_EDMSG(Object::cast_to<Message>(message)->get_signers().size() != signatures.size(), "Transaction does not have enough signers.");

PackedByteArray serialized_bytes = serialize();

Callable pending_blockhash_callback(this, "send");
Expand Down

0 comments on commit 8be5065

Please sign in to comment.