Add String() method to Transaction type

This commit is contained in:
gagliardetto 2022-02-09 00:23:00 +01:00
parent 965a81dfc1
commit 3db9225618
1 changed files with 10 additions and 0 deletions

View File

@ -18,6 +18,7 @@
package solana
import (
"bytes"
"errors"
"fmt"
"sort"
@ -351,6 +352,15 @@ func (tx *Transaction) EncodeTree(encoder *text.TreeEncoder) (int, error) {
return encoder.WriteString(encoder.Tree.String())
}
func (tx *Transaction) String() string {
buf := new(bytes.Buffer)
_, err := tx.EncodeTree(text.NewTreeEncoder(buf, text.Bold("")))
if err != nil {
panic(err)
}
return buf.String()
}
func (tx *Transaction) EncodeToTree(parent treeout.Branches) {
parent.ParentFunc(func(txTree treeout.Branches) {