forked from LBRYCommunity/lbry-sdk
send dict instead of Account and PubKey objects when adding keys
This commit is contained in:
parent
1a4a2db1b1
commit
2ec91dbca7
2 changed files with 12 additions and 18 deletions
|
@ -290,7 +290,15 @@ class Database:
|
||||||
return address
|
return address
|
||||||
|
|
||||||
async def add_keys(self, account, chain, pubkeys):
|
async def add_keys(self, account, chain, pubkeys):
|
||||||
return await self.run(q.add_keys, account, chain, pubkeys)
|
return await self.run(q.add_keys, [{
|
||||||
|
'account': account.id,
|
||||||
|
'address': k.address,
|
||||||
|
'chain': chain,
|
||||||
|
'pubkey': k.pubkey_bytes,
|
||||||
|
'chain_code': k.chain_code,
|
||||||
|
'n': k.n,
|
||||||
|
'depth': k.depth
|
||||||
|
} for k in pubkeys])
|
||||||
|
|
||||||
async def get_transactions(self, **constraints) -> Result[Transaction]:
|
async def get_transactions(self, **constraints) -> Result[Transaction]:
|
||||||
return await self.fetch_result(q.get_transactions, **constraints)
|
return await self.fetch_result(q.get_transactions, **constraints)
|
||||||
|
|
|
@ -58,21 +58,7 @@ def get_all_addresses(self):
|
||||||
return context().execute(select(PubkeyAddress.c.address))
|
return context().execute(select(PubkeyAddress.c.address))
|
||||||
|
|
||||||
|
|
||||||
def add_keys(account, chain, pubkeys):
|
def add_keys(pubkeys):
|
||||||
c = context()
|
c = context()
|
||||||
c.execute(
|
c.execute(c.insert_or_ignore(PubkeyAddress).values([{'address': k['address']} for k in pubkeys]))
|
||||||
c.insert_or_ignore(PubkeyAddress)
|
c.execute(c.insert_or_ignore(AccountAddress).values(pubkeys))
|
||||||
.values([{'address': k.address} for k in pubkeys])
|
|
||||||
)
|
|
||||||
c.execute(
|
|
||||||
c.insert_or_ignore(AccountAddress)
|
|
||||||
.values([{
|
|
||||||
'account': account.id,
|
|
||||||
'address': k.address,
|
|
||||||
'chain': chain,
|
|
||||||
'pubkey': k.pubkey_bytes,
|
|
||||||
'chain_code': k.chain_code,
|
|
||||||
'n': k.n,
|
|
||||||
'depth': k.depth
|
|
||||||
} for k in pubkeys])
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in a new issue