Skip to content
This repository was archived by the owner on May 30, 2022. It is now read-only.

Commit 1ea69c7

Browse files
authored
Merge pull request #7 from crossle/master
Export transaction format and set signature
2 parents c8d475a + c4df6f3 commit 1ea69c7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tx/transaction.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ func (t *Transaction) SetID(id []byte) {
104104
t.id = id
105105
}
106106

107+
func (t *Transaction) SetSignature(signature []byte) {
108+
t.signature = signature
109+
}
110+
107111
// Signature returns the signature of the transaction
108112
func (t *Transaction) Signature() string {
109113
return utils.EncodeToBase64(t.signature)
@@ -114,7 +118,7 @@ func (t *Transaction) Signature() string {
114118
// the signature
115119
func (t *Transaction) Sign(w arweave.WalletSigner) (*Transaction, error) {
116120
// format the message
117-
payload, err := t.formatMsgBytes()
121+
payload, err := t.FormatMsgBytes()
118122
if err != nil {
119123
return nil, err
120124
}
@@ -192,11 +196,11 @@ func (t *Transaction) UnmarshalJSON(input []byte) error {
192196
return nil
193197
}
194198

195-
// formatMsgBytes formats the message that needs to be signed. All fields
199+
// FormatMsgBytes formats the message that needs to be signed. All fields
196200
// need to be an array of bytes originating from the necessary data (not base64url encoded).
197201
// The signing message is the SHA256 of the concatenation of the byte arrays
198202
// of the owner public key, target address, data, quantity, reward and last transaction
199-
func (t *Transaction) formatMsgBytes() ([]byte, error) {
203+
func (t *Transaction) FormatMsgBytes() ([]byte, error) {
200204
var msg []byte
201205
lastTx, err := utils.DecodeString(t.LastTx())
202206
if err != nil {

0 commit comments

Comments
 (0)