Re-level non-docs content to top of repo and rename content→docs

This commit is contained in:
mDuo13
2024-01-31 16:24:01 -08:00
parent f841ef173c
commit c10beb85c2
2907 changed files with 1 additions and 1 deletions

View File

@@ -0,0 +1,68 @@
if (typeof module !== "undefined") {
// Use var here because const/let are block-scoped to the if statement.
var xrpl = require('xrpl')
}
// Blackhole an account.
// For some addresses, it's possible that no one has the secret key, in which case the account is a black hole and the XRP is lost forever.
// https://xrpl.org/accounts.html#special-addresses
// https://xrpl.org/disable-master-key-pair.html#disable-master-key-pair
async function main() {
// Connect to a testnet node
console.log("Connecting to Testnet...")
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
await client.connect()
// Get account credentials from the Testnet Faucet
console.log("Requesting an account from the Testnet faucet...")
const { wallet, balance } = await client.fundWallet()
console.log("\nAccount: ", wallet.address)
console.log(" Seed: ", wallet.seed)
// This is a well known blackhole address
const blackhole_address = "rrrrrrrrrrrrrrrrrrrrBZbvji"
// Send AccountSet transaction
const SetRegularKey_tx = await client.autofill({
"TransactionType": "SetRegularKey",
"Account": wallet.address,
"RegularKey": blackhole_address
})
const SetRegularKey_tx_signed = wallet.sign(SetRegularKey_tx)
const SetRegularKey_tx_result = await client.submitAndWait(SetRegularKey_tx_signed.tx_blob)
console.log(`\n Submitted a SetRegularKey transaction (Result: ${SetRegularKey_tx_result.result.meta.TransactionResult})`)
console.log(` Transaction hash: ${SetRegularKey_tx_signed.hash}`)
// Send AccountSet transaction
const DisableMasterKey_tx = await client.autofill({
"TransactionType": "AccountSet",
"Account": wallet.address,
"SetFlag": xrpl.AccountSetAsfFlags.asfDisableMaster
})
const DisableMasterKey_tx_signed = wallet.sign(DisableMasterKey_tx)
const DisableMasterKey_tx_result = await client.submitAndWait(DisableMasterKey_tx_signed.tx_blob)
console.log(`\n Submitted a DisableMasterKey transaction (Result: ${DisableMasterKey_tx_result.result.meta.TransactionResult}`)
console.log(` Transaction hash: ${DisableMasterKey_tx_signed.hash}`)
const response = await client.request({
"command": "account_info",
"account": wallet.address,
"ledger_index": "validated"
})
if (response.result.account_data.Flags == 1114112) {
console.log(`\nAccount ${wallet.address}'s master key has been disabled, the account is now blackholed.`)
} else {
console.log(`\nAccount ${wallet.address}'s master key is still enabled, account is NOT blackholed.`)
}
client.disconnect()
// End main()
}
main()

View File

@@ -0,0 +1,63 @@
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions import AccountSet, SetRegularKey, AccountSetAsfFlag
from xrpl.transaction import submit_and_wait
from xrpl.wallet import generate_faucet_wallet
from xrpl.models.requests import AccountInfo
# This code sample will blackhole an account
# A funded account on the testnet is provided for testing purposes
# https://xrpl.org/accounts.html#special-addresses
asfDisableMaster = 1114112
# Connect to a testnet node
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
client = JsonRpcClient(JSON_RPC_URL)
# Get credentials from the Testnet Faucet
print("Requesting an account from the Testnet faucet...")
test_wallet = generate_faucet_wallet(client=client)
myAddr = test_wallet.address
print(f"\n Account: {test_wallet.address}")
print(f" Seed: {test_wallet.seed}")
# This is a well known blackhole address
blackhole_address = "rrrrrrrrrrrrrrrrrrrrBZbvji"
# Construct SetRegularKey transaction
tx_regulary_key = SetRegularKey(
account=myAddr,
regular_key=blackhole_address
)
# Sign and submit the transaction
submit_tx_regular = submit_and_wait(transaction=tx_regulary_key, client=client, wallet=test_wallet)
submit_tx_regular = submit_tx_regular.result
print(f"\n Submitted a SetRegularKey tx. Result: {submit_tx_regular['meta']['TransactionResult']}")
print(f" Tx content: {submit_tx_regular}")
# Construct AccountSet transaction w/ asfDisableMaster flag
# This permanently blackholes an account!
tx_disable_master_key = AccountSet(
account=myAddr,
set_flag=AccountSetAsfFlag.ASF_DISABLE_MASTER
)
# Sign and submit the transaction
submit_tx_disable = submit_and_wait(transaction=tx_disable_master_key, client=client, wallet=test_wallet)
submit_tx_disable = submit_tx_disable.result
print(f"\n Submitted a DisableMasterKey tx. Result: {submit_tx_disable['meta']['TransactionResult']}")
print(f" Tx content: {submit_tx_disable}")
# Verify Account Settings
get_acc_flag = AccountInfo(
account=myAddr
)
response = client.request(get_acc_flag)
if response.result['account_data']['Flags'] & asfDisableMaster:
print(f"\nAccount {myAddr}'s master key has been disabled, account is blackholed.")
else:
print(f"\nAccount {myAddr}'s master key is still enabled, account is NOT blackholed")