Skip to content

Commit 26e605c

Browse files
committed
Remove metasv provider
Signed-off-by: aaron67 <[email protected]>
1 parent 7ca2a52 commit 26e605c

File tree

8 files changed

+7
-107
lines changed

8 files changed

+7
-107
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A Bitcoin SV (BSV) Python Library that is extremely simple to use but more.
1212
- P2PKH, P2PK, and bare-multisig supported
1313
- All the SIGHASH flags supported
1414
- Additional script types can be customized
15-
- [MetaSV](https://metasv.com/) and [WhatsOnChain](https://developers.whatsonchain.com/) API integrated
15+
- [WhatsOnChain](https://developers.whatsonchain.com/) API integrated
1616
- Ability to adapt to different service providers
1717
- Fully ECDSA implementation
1818
- ECDH and Electrum ECIES (aka BIE1) implementation

bsvlib/constants.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from enum import Enum
3-
from typing import Dict, List, Optional
3+
from typing import Dict, List
44

55
TRANSACTION_SEQUENCE: int = int(os.getenv('BSVLIB_TRANSACTION_SEQUENCE') or 0xffffffff)
66
TRANSACTION_VERSION: int = int(os.getenv('BSVLIB_TRANSACTION_VERSION') or 1)
@@ -11,7 +11,6 @@
1111
THREAD_POOL_MAX_EXECUTORS: int = int(os.getenv('BSVLIB_THREAD_POOL_MAX_EXECUTORS') or 10)
1212
BIP39_ENTROPY_BIT_LENGTH: int = int(os.getenv('BSVLIB_BIP39_ENTROPY_BIT_LENGTH') or 128)
1313
BIP44_DERIVATION_PATH = os.getenv('BSVLIB_BIP44_DERIVATION_PATH') or "m/44'/236'/0'"
14-
METASV_TOKEN: Optional[str] = os.getenv('BSVLIB_METASV_TOKEN') or os.getenv('METASV_TOKEN')
1514

1615

1716
class Chain(str, Enum):

bsvlib/service/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from .metasv import MetaSV
21
from .provider import Provider, BroadcastResult
32
from .service import Service
43
from .whatsonchain import WhatsOnChain

bsvlib/service/metasv.py

-74
This file was deleted.

bsvlib/service/service.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from typing import List, Dict, Optional
22

3-
from .metasv import MetaSV
43
from .provider import Provider, BroadcastResult
54
from .whatsonchain import WhatsOnChain
6-
from ..constants import Chain, METASV_TOKEN
5+
from ..constants import Chain
76

87

98
class Service:
@@ -13,7 +12,7 @@ def __init__(self, chain: Optional[Chain] = None, provider: Optional[Provider] =
1312
self.provider = provider
1413
else:
1514
chain = chain or Chain.MAIN
16-
self.provider = MetaSV(token=METASV_TOKEN) if chain == Chain.MAIN and METASV_TOKEN else WhatsOnChain(chain)
15+
self.provider = WhatsOnChain(chain)
1716
self.chain = self.provider.chain
1817

1918
def get_unspents(self, **kwargs) -> List[Dict]:

examples/merge_unspents.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import requests
44

55
from bsvlib import Transaction, Key, Unspent
6-
from bsvlib.service import MetaSV
76

87
MIN_CONSOLIDATION_INPUTS = 100
98
MERGE_COUNT = 3000
@@ -13,11 +12,11 @@
1312

1413

1514
def get_block_height() -> int:
16-
return requests.get('https://apiv2.metasv.com/block/info').json()['blocks']
15+
return requests.get('https://api.whatsonchain.com/v1/bsv/main/chain/info').json()['blocks']
1716

1817

1918
def pick_confirmed(wif):
20-
unspents = Unspent.get_unspents(provider=MetaSV(), private_keys=[Key(wif)])
19+
unspents = Unspent.get_unspents(private_keys=[Key(wif)])
2120
print(f'total {len(unspents)}')
2221
current_height = get_block_height()
2322
picked = []

tests/test_service.py

-13
This file was deleted.

tests/test_wallet.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from bsvlib.constants import Chain
22
from bsvlib.keys import Key
3-
from bsvlib.script.type import P2pkScriptType
43
from bsvlib.service.whatsonchain import WhatsOnChain
54
from bsvlib.wallet import Wallet
65

@@ -45,12 +44,4 @@ def test():
4544
w2.get_unspents(refresh=True)
4645
assert w2.get_balance() == w2.get_balance(refresh=True)
4746

48-
has_p2pk = False
49-
for unspent in w2.get_unspents():
50-
if unspent.script_type == P2pkScriptType():
51-
has_p2pk = True
52-
break
53-
if has_p2pk:
54-
assert w1.get_balance() < w2.get_balance()
55-
else:
56-
assert w1.get_balance() == w2.get_balance()
47+
assert w1.get_balance() == w2.get_balance()

0 commit comments

Comments
 (0)