Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
814910ce
Unverified
Commit
814910ce
authored
May 21, 2021
by
Ralph Pichler
Committed by
GitHub
May 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: correctly check and decode transaction hash (#1810)
parent
7a8dea9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
node.go
pkg/node/node.go
+19
-4
No files found.
pkg/node/node.go
View file @
814910ce
...
...
@@ -10,6 +10,7 @@ package node
import
(
"context"
"crypto/ecdsa"
"encoding/hex"
"errors"
"fmt"
"io"
...
...
@@ -18,6 +19,7 @@ import (
"net"
"net/http"
"path/filepath"
"strings"
"time"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -288,7 +290,7 @@ func NewBee(addr string, swarmAddress swarm.Address, publicKey ecdsa.PublicKey,
txHash
,
err
:=
getTxHash
(
stateStore
,
logger
,
o
)
if
err
!=
nil
{
return
nil
,
errors
.
New
(
"no transaction hash provided or found"
)
return
nil
,
fmt
.
Errorf
(
"invalid transaction hash: %w"
,
err
)
}
senderMatcher
:=
transaction
.
NewMatcher
(
swapBackend
,
types
.
NewEIP155Signer
(
big
.
NewInt
(
chainID
)))
...
...
@@ -754,16 +756,29 @@ func getTxHash(stateStore storage.StateStorer, logger logging.Logger, o Options)
if
o
.
Standalone
{
return
nil
,
nil
// in standalone mode tx hash is not used
}
if
len
(
o
.
Transaction
)
==
32
{
logger
.
Info
(
"using the provided transaction hash"
)
return
[]
byte
(
o
.
Transaction
),
nil
if
o
.
Transaction
!=
""
{
txHashTrimmed
:=
strings
.
TrimPrefix
(
o
.
Transaction
,
"0x"
)
if
len
(
txHashTrimmed
)
!=
64
{
return
nil
,
errors
.
New
(
"invalid length"
)
}
txHash
,
err
:=
hex
.
DecodeString
(
txHashTrimmed
)
if
err
!=
nil
{
return
nil
,
err
}
logger
.
Infof
(
"using the provided transaction hash %x"
,
txHash
)
return
txHash
,
nil
}
var
txHash
common
.
Hash
key
:=
chequebook
.
ChequebookDeploymentKey
if
err
:=
stateStore
.
Get
(
key
,
&
txHash
);
err
!=
nil
{
if
errors
.
Is
(
err
,
storage
.
ErrNotFound
)
{
return
nil
,
errors
.
New
(
"chequebook deployment transaction hash not found. Please specify the transaction hash manually."
)
}
return
nil
,
err
}
logger
.
Infof
(
"using the chequebook transaction hash %x"
,
txHash
)
return
txHash
.
Bytes
(),
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment