@@ -31,6 +31,7 @@ import (
31
31
"github.com/BitBoxSwiss/bitbox-wallet-app/util/errp"
32
32
"github.com/ethereum/go-ethereum"
33
33
"github.com/ethereum/go-ethereum/common"
34
+ "github.com/ethereum/go-ethereum/common/hexutil"
34
35
"github.com/ethereum/go-ethereum/core/types"
35
36
"golang.org/x/time/rate"
36
37
)
@@ -129,7 +130,33 @@ func (blockbook *Blockbook) Transactions(blockTipHeight *big.Int, address common
129
130
130
131
// SendTransaction implements rpc.Interface.
131
132
func (blockbook * Blockbook ) SendTransaction (ctx context.Context , tx * types.Transaction ) error {
132
- return fmt .Errorf ("Not yet implemented" )
133
+ params := url.Values {}
134
+
135
+ result := struct {
136
+ Txid string `json:"result,omitempty"`
137
+ Error struct {
138
+ Message string `json:"message,omitempty"`
139
+ } `json:"error,omitempty"`
140
+ }{}
141
+
142
+ encodedTx , err := tx .MarshalBinary ()
143
+ if err != nil {
144
+ blockbook .log .Errorf ("Failed to marshal transaction: %v" , err )
145
+ return errp .WithStack (err )
146
+ }
147
+
148
+ if err := blockbook .call (ctx , path .Join ("sendtx" , hexutil .Encode (encodedTx )), params , & result ); err != nil {
149
+ blockbook .log .Errorf ("Failed to send transaction: %v" , err )
150
+ return errp .WithStack (err )
151
+ }
152
+
153
+ if result .Error .Message != "" {
154
+ blockbook .log .Errorf ("Error sending transaction: %s" , result .Error .Message )
155
+ return errp .Newf ("error sending transaction: %s" , result .Error .Message )
156
+ }
157
+
158
+ blockbook .log .Infof ("Transaction sent: %s" , result .Txid )
159
+ return nil
133
160
}
134
161
135
162
// ERC20Balance implements rpc.Interface.
0 commit comments