Hashpack / hashconnect

Hashconnect library, readme in progress
BSD Zero Clause License
45 stars 38 forks source link

HashConnect signTransaction returns wrong signature #207

Closed amolinaarribere closed 4 months ago

amolinaarribere commented 4 months ago

Hashconnect version : 3.0.13 Hashpack version : 9.8.1 @hashgraph/sdk version : 2.41.0

import { Transaction, Signer, AccountId } from '@hashgraph/sdk';
import { HashConnect} from 'hashconnect';

export class HashpackTransactionAdapter{
   private hc: HashConnect;
   public signer: Signer ;
   public account: AccountId;

   constructor(){
        this.hc = new HashConnect(hashpackNetwork, projectId, {
                name: SDK.appMetadata.name,
                description: SDK.appMetadata.description,
                url: SDK.appMetadata.url,
                icons: [],
            });
   }

   private async setSigner(): Promise<void> {
        this.signer = this.hc.getSigner(this.account);
   }

   async sign(message: Transaction): Promise<string> {
                       const signedTrans = await this.signer.signTransaction(message);
               const list = signedTrans.getSignatures();
                       const nodes_signature = list.get(
                this.networkService.consensusNodes[0].nodeId,
            );
                       const pk_signature = nodes_signature.get(PublicKey_Der_Encoded);
   }
}

The retrieved signature "pk_signature" is apparently wrong, Hedera Testnet returns an "INVALID_SIGNATURE" error when we add the signature to the original transaction then submit it.