tronprotocol / trident

133 stars 105 forks source link

make signed transaction offline #100

Closed fereshteh-jvz closed 2 months ago

fereshteh-jvz commented 11 months ago

How to make signed transaction offline? Right now I can make signed transaction with apiWrapper. But in my case I cannot connect to nodes and I need to create and sign the transaction offline so I can broadcast it with https://api.trongrid.io/wallet/broadcasttransaction api. Thanks in advance for your help

lxcmyf commented 11 months ago

@fereshteh-jvz Please refer to trident sdk, https://github.com/tronprotocol/trident/blob/master/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java

public Chain.Transaction signTransaction(Response.TransactionExtention txnExt, KeyPair keyPair) {
        byte[] txid = txnExt.getTxid().toByteArray();
        byte[] signature = KeyPair.signTransaction(txid, keyPair);
        Chain.Transaction signedTxn = txnExt.getTransaction().toBuilder().addSignature(ByteString.copyFrom(signature)).build();
        return signedTxn;
    }
eodiandie commented 2 months ago

will close this issue, seems this issue has been resolved already.