Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
beem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
beem
Commits
28de6c89
Commit
28de6c89
authored
8 years ago
by
Fabian Schuh
Browse files
Options
Downloads
Patches
Plain Diff
[TransactionBuilder] Make sure we have a wif key to sign a tx
parent
f9db2244
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bitshares/transactionbuilder.py
+14
-5
14 additions, 5 deletions
bitshares/transactionbuilder.py
with
14 additions
and
5 deletions
bitshares/transactionbuilder.py
+
14
−
5
View file @
28de6c89
...
...
@@ -6,6 +6,7 @@ from bitsharesbase import transactions, operations
from
.exceptions
import
(
InsufficientAuthorityError
,
MissingKeyError
,
InvalidWifError
)
from
.
import
bitshares
as
bts
import
logging
...
...
@@ -14,7 +15,7 @@ log = logging.getLogger(__name__)
class
TransactionBuilder
(
dict
):
def
__init__
(
self
,
tx
=
None
,
bitshares_instance
=
None
):
def
__init__
(
self
,
tx
=
{}
,
bitshares_instance
=
None
):
if
not
bitshares_instance
:
bitshares_instance
=
bts
.
BitShares
()
self
.
bitshares
=
bitshares_instance
...
...
@@ -22,7 +23,7 @@ class TransactionBuilder(dict):
self
.
op
=
[]
self
.
wifs
=
[]
if
not
isinstance
(
tx
,
dict
):
raise
ValueError
(
"
Invalid Transaction Format
"
)
raise
ValueError
(
"
Invalid Transaction
Builder
Format
"
)
super
(
TransactionBuilder
,
self
).
__init__
(
tx
)
def
appendOps
(
self
,
ops
):
...
...
@@ -44,7 +45,12 @@ class TransactionBuilder(dict):
self
.
wifs
.
append
(
wif
)
def
appendWif
(
self
,
wif
):
self
.
wifs
.
append
(
wif
)
if
wif
:
try
:
PrivateKey
(
wif
)
self
.
wifs
.
append
(
wif
)
except
:
raise
InvalidWifError
def
constructTx
(
self
):
if
isinstance
(
self
.
op
,
list
):
...
...
@@ -74,7 +80,10 @@ class TransactionBuilder(dict):
try
:
signedtx
=
Signed_Transaction
(
**
self
.
json
())
except
:
raise
ValueError
(
"
Invalid Transaction Format
"
)
raise
ValueError
(
"
Invalid TransactionBuilder Format
"
)
if
not
any
(
self
.
wifs
):
raise
MissingKeyError
signedtx
.
sign
(
self
.
wifs
)
self
[
"
signatures
"
].
extend
(
signedtx
.
json
().
get
(
"
signatures
"
))
...
...
@@ -95,7 +104,7 @@ class TransactionBuilder(dict):
raise
e
try
:
self
.
bitshares
.
rpc
.
broadcast_transaction
(
self
.
tx
,
api
=
"
network_broadcast
"
)
self
.
bitshares
.
rpc
.
broadcast_transaction
(
self
.
tx
.
json
()
,
api
=
"
network_broadcast
"
)
except
Exception
as
e
:
raise
e
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment