예제 #1
0
 def test_all_fields(self):
     regular_key = Wallet.create().classic_address
     response = submit_transaction(
         SetRegularKey(
             account=WALLET.classic_address,
             sequence=WALLET.next_sequence_num,
             regular_key=regular_key,
         ),
         WALLET,
     )
     self.assertTrue(response.is_successful())
     WALLET.next_sequence_num += 1
예제 #2
0
 async def test_all_fields(self, client):
     regular_key = Wallet.create().classic_address
     response = await submit_transaction_async(
         SetRegularKey(
             account=WALLET.classic_address,
             sequence=WALLET.sequence,
             regular_key=regular_key,
         ),
         WALLET,
     )
     self.assertTrue(response.is_successful())
     WALLET.sequence += 1
예제 #3
0
 def payment(self, destination, sender, amount, sequence, seed) -> bool:
     my_tx_payment = Payment(
         account=sender,
         amount=xrp_to_drops(amount),
         destination=destination,
         sequence=sequence,
     )
     sign_wallet = Wallet(seed, sequence)
     my_tx_payment_signed = safe_sign_and_autofill_transaction(
         my_tx_payment, sign_wallet, self.client)
     tx_response = send_reliable_submission(my_tx_payment_signed,
                                            self.client)
     return True
예제 #4
0
 async def test_basic_functionality(self, client):
     issuer_wallet = Wallet.create()
     response = await submit_transaction_async(
         TrustSet(
             account=WALLET.classic_address,
             sequence=WALLET.sequence,
             flags=TrustSetFlag.TF_SET_NO_RIPPLE,
             limit_amount=IssuedCurrencyAmount(
                 issuer=issuer_wallet.classic_address,
                 currency="USD",
                 value="100",
             ),
         ),
         WALLET,
     )
     self.assertTrue(response.is_successful())
     WALLET.sequence += 1
예제 #5
0
 def test_basic_functionality(self):
     issuer_wallet = Wallet.create()
     response = submit_transaction(
         TrustSet(
             account=WALLET.classic_address,
             sequence=WALLET.next_sequence_num,
             fee=FEE,
             flags=TrustSetFlag.TF_SET_NO_RIPPLE,
             limit_amount=IssuedCurrencyAmount(
                 issuer=issuer_wallet.classic_address,
                 currency="USD",
                 value="100",
             ),
         ),
         WALLET,
     )
     self.assertTrue(response.is_successful())
예제 #6
0
 def test_add_signer(self):
     # sets up another signer for this account
     other_signer = Wallet.create()
     response = submit_transaction(
         SignerListSet(
             account=WALLET.classic_address,
             sequence=WALLET.sequence,
             signer_quorum=1,
             signer_entries=[
                 SignerEntry(
                     account=other_signer.classic_address,
                     signer_weight=1,
                 ),
             ],
         ),
         WALLET,
     )
     self.assertTrue(response.is_successful())
     WALLET.sequence += 1
예제 #7
0
# Example Credentials ----------------------------------------------------------
from xrpl.wallet import Wallet
test_wallet = Wallet(seed="sn3nxiW7v8KXzPzAqzyHXbSSKNuN9", sequence=16237283)
print(test_wallet.classic_address)  # "rMCcNuTcajgw7YTgBy1sys3b89QqjUrMpH"

# Connect ----------------------------------------------------------------------
import xrpl
testnet_url = "https://s.altnet.rippletest.net:51234"
client = xrpl.clients.JsonRpcClient(testnet_url)

# Get credentials from the Testnet Faucet -----------------------------------
# For production, instead create a Wallet instance as above
faucet_url = "https://faucet.altnet.rippletest.net/accounts"
print("Getting a new account from the Testnet faucet...")
from xrpl.wallet import generate_faucet_wallet
test_wallet = generate_faucet_wallet(client, debug=True)

# Prepare transaction ----------------------------------------------------------
import xrpl.utils  # workaround for https://github.com/XRPLF/xrpl-py/issues/222
my_payment = xrpl.models.transactions.Payment(
    account=test_wallet.classic_address,
    amount=xrpl.utils.xrp_to_drops(22),
    destination="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
)
print("Payment object:", my_payment)

# Sign transaction -------------------------------------------------------------
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
    my_payment, test_wallet, client)
max_ledger = signed_tx.last_ledger_sequence
print("Signed transaction:", signed_tx)
예제 #8
0
    test_async_and_sync,
)
from tests.integration.reusable_values import DESTINATION, WALLET
from xrpl.asyncio.account import (
    does_account_exist,
    get_account_info,
    get_account_transactions,
    get_balance,
    get_latest_transaction,
)
from xrpl.core.addresscodec import classic_address_to_xaddress
from xrpl.models.transactions import Payment
from xrpl.wallet import Wallet, generate_faucet_wallet

NEW_WALLET = generate_faucet_wallet(JSON_RPC_CLIENT)
EMPTY_WALLET = Wallet.create()


class TestAccount(IntegrationTestCase):
    @test_async_and_sync(globals(), ["xrpl.account.does_account_exist"])
    async def test_does_account_exist_true(self, client):
        self.assertTrue(await does_account_exist(WALLET.classic_address,
                                                 client))

    @test_async_and_sync(globals(), ["xrpl.account.does_account_exist"])
    async def test_does_account_exist_false(self, client):
        address = "rG1QQv2nh2gr7RCZ1P8YYcBUcCCN633jCn"
        self.assertFalse(await does_account_exist(address, client))

    @test_async_and_sync(globals(), ["xrpl.account.does_account_exist"])
    async def test_does_account_exist_xaddress(self, client):
예제 #9
0
    def test_basic_functionality(self):
        #
        # Perform multisign
        #
        # NOTE: If you need to use xrpl-py for multisigning, please create an issue on
        # the repo. We'd like to gauge interest in higher level multisigning
        # functionality.
        issuer = Wallet.create()
        tx = TrustSet(
            account=WALLET.classic_address,
            sequence=WALLET.next_sequence_num,
            fee=FEE,
            flags=TrustSetFlag.TF_SET_NO_RIPPLE,
            limit_amount=IssuedCurrencyAmount(
                issuer=issuer.classic_address,
                currency="USD",
                value="10",
            ),
        )
        tx_json = transaction_json_to_binary_codec_form(tx.to_dict())
        first_sig = sign(
            bytes.fromhex(
                encode_for_multisigning(
                    tx_json,
                    FIRST_SIGNER.classic_address,
                )),
            FIRST_SIGNER.private_key,
        )
        second_sig = sign(
            bytes.fromhex(
                encode_for_multisigning(
                    tx_json,
                    SECOND_SIGNER.classic_address,
                )),
            SECOND_SIGNER.private_key,
        )
        multisigned_tx = TrustSet(
            account=WALLET.classic_address,
            sequence=WALLET.next_sequence_num,
            fee=FEE,
            flags=TrustSetFlag.TF_SET_NO_RIPPLE,
            limit_amount=IssuedCurrencyAmount(
                issuer=issuer.classic_address,
                currency="USD",
                value="10",
            ),
            signers=[
                Signer(
                    account=FIRST_SIGNER.classic_address,
                    txn_signature=first_sig,
                    signing_pub_key=FIRST_SIGNER.public_key,
                ),
                Signer(
                    account=SECOND_SIGNER.classic_address,
                    txn_signature=second_sig,
                    signing_pub_key=SECOND_SIGNER.public_key,
                ),
            ],
        )

        # submit tx
        response = JSON_RPC_CLIENT.request(
            SubmitMultisigned(tx_json=transaction_json_to_binary_codec_form(
                multisigned_tx.to_dict()), ))
        self.assertTrue(response.is_successful())
예제 #10
0
from xrpl.models.requests import SubmitMultisigned
from xrpl.models.transactions import (
    Signer,
    SignerEntry,
    SignerListSet,
    TrustSet,
    TrustSetFlag,
)
from xrpl.transaction import transaction_json_to_binary_codec_form
from xrpl.wallet import Wallet

FEE = get_fee(JSON_RPC_CLIENT)

#
# Set up signer list
FIRST_SIGNER = Wallet.create()
SECOND_SIGNER = Wallet.create()
LIST_SET_TX = sign_and_reliable_submission(
    SignerListSet(
        account=WALLET.classic_address,
        sequence=WALLET.next_sequence_num,
        last_ledger_sequence=WALLET.next_sequence_num + 10,
        fee=FEE,
        signer_quorum=2,
        signer_entries=[
            SignerEntry(
                account=FIRST_SIGNER.classic_address,
                signer_weight=1,
            ),
            SignerEntry(
                account=SECOND_SIGNER.classic_address,
예제 #11
0
# Define signer address
import os
my_secret = os.getenv("MYSECRET")
from xrpl.wallet import Wallet
wallet = Wallet(seed=my_secret, sequence=16237283)
print(wallet.classic_address)  # "raaFKKmgf6CRZttTVABeTcsqzRQ51bNR6Q"

from xrpl.models.transactions import Payment
from xrpl.utils import xrp_to_drops
my_payment = Payment(
    account=wallet.classic_address,
    amount=xrp_to_drops(22),
    fee="10",
    destination="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
    sequence=wallet.
    sequence,  # this needs to be incremented upon every successful transaction
)
print("Payment object:", my_payment)

# Sign transaction -------------------------------------------------------------
import xrpl.transaction
signed = xrpl.transaction.safe_sign_transaction(my_payment, wallet)
print("Signed transaction blob:", signed)
예제 #12
0
# Define signer address
import os  
my_secret = os.getenv("MYSECRET")
from xrpl.wallet import Wallet
wallet = Wallet(seed="MYSECRET", sequence=16237283)
print(wallet.classic_address) # "raaFKKmgf6CRZttTVABeTcsqzRQ51bNR6Q"

from xrpl.models.transactions import Payment
from xrpl.utils import xrp_to_drops
my_payment = Payment(
    account=wallet.classic_address,
    amount=xrp_to_drops(22),
    fee="10",
    destination="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
    sequence=16126889,
)
print("Payment object:", my_payment)

# Sign transaction -------------------------------------------------------------
import xrpl.transaction 
signed = xrpl.transaction.safe_sign_transaction(my_payment, wallet)
print("Signed transaction blob:", signed)